ECshop模板中怎么 控制foreach 的循环次数,只循环5次怎么做:

<ul>
<!-- {foreach from=$promotion_info item=item key=key} -->
<li><!-- {if $item.type eq "snatch"} -->
<a href="snatch.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.snatch_promotion}</a>
<!-- {elseif $item.type eq "group_buy"} -->
<a href="group_buy.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.group_promotion}</a>
<!-- {elseif $item.type eq "auction"} -->
<a href="auction.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.auction_promotion}</a>
<!-- {elseif $item.type eq "favourable"} -->
<a href="activity.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.favourable_promotion}</a>
<!-- {elseif $item.type eq "package"} -->
<a href="package.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.package_promotion}</a>
<!-- {/if} -->
<a href="{$item.url}" title="{$lang.$item.type} {$item.act_name}{$item.time}">{$item.act_name}</a></li>
<!-- {/foreach} -->
</ul>
这样可以让他只输出5 次 循环次数还是根据数组长度来的 没有找到怎么限制 iteration 这岩迅余表示循环次数粗滚是昌孝从1 开始的 还要保证 foreeach的name 唯一不然会报错

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

<li><!-- {if $item.type eq "snatch"} -->
<a href="snatch.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.snatch_promotion}</a>
<!-- {elseif $item.type eq "group_buy"} -->
<a href="group_buy.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.group_promotion}</a>
<!-- {elseif $item.type eq "auction"} -->
<a href="auction.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.auction_promotion}</a>
<!-- {elseif $item.type eq "favourable"} -->
<a href="activity.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.favourable_promotion}</a>
<!-- {elseif $item.type eq "package"} -->
<a href="package.php" title="{$lang.$item.type}" style="color:#06c;">{$lang.package_promotion}</a>
<!-- {/if} -->
<a href="{$item.url}" title="{$lang.$item.type} {$item.act_name}{$item.time}">{$item.act_name}</a></li>
{/if}

<!-- {/foreach} -->
</ul>