ecshop循环计数

时间:2023-12-30 13:11:50

循环依次递增+1

<!-- {foreach from=$comments item=comment name=comment} -->
{$smarty.foreach.comment.iteration}
<!-- {/foreach} -->

循环依次递增+1(初始值从1开始)

<!-- {foreach from=$comments item=comment name=comment} -->
{$smarty.foreach.comment.index}
<!-- {/foreach} -->

循环依次递增+1(初始值从0开始)

判断循环次数

<!-- {foreach from=$promotion_info item=item name=name} -->
{if $smarty.foreach.name.iteration <= 5}{/if}
<!-- {/foreach} -->