欢迎访问 舍力博客(www.syom.cn)
限制某个参数调用的数量:
<!-- {if $smarty.foreach.参数.index lt 数量}-->代码<!-- {/if} -->
控制当某个参数少于多少时的显示方式:
<!-- {if $smarty.foreach.参数.iteration<数量}-->代码<!-- {/if} -->
以上的参数函数如下(提供部分):
排行榜:top_goods
热门商品:hot_goods
精品推荐:best_goods
新品上市:new_goods
分类商品:cat_goods
最新文章:new_articles
举例:
<!-- {foreach name=top_goods from=$top_goods item=goods}-->
<!-- {if $smarty.foreach.top_goods.iteration<3}--><ul class="topcp_tp"><li><a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="samllimg" /></a></li></ul><!-- {/if} -->
<!-- {if $smarty.foreach.top_goods.iteration>3}--><ul class="topcp_wz"><li><a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.short_name}</a></li></ul><!-- {/if} -->
<!-- {/foreach} -->
留言/评论:◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。