ecshop中调用smarty的foreach-iteration函数
翻阅smarty手册,查看iteration函数的应用:iteration用于循环的次数。注意:iteration 不像index属性受start、step和max属性的影响,该值总是从1开始(index是从0开始的).rownum 是iteration的别名,两者等同.
看到很多ecshop的站点底部的文章信息的图片都是不同的。之前一直不知道如何调用的。后来看了默认模板就明白了。其实在默认模板中的top10.lbi也就是销售排行这里早就实现了这个功能。Iteration其实是foreach的name键值。{foreach name=top_goods from=$top_goods item=goods}
这个是ecshop销售排行的模板,他通过巧妙使用foreach来实现了图标的对应.<img src=”../images/top_{$smarty.foreach.top_goods.iteration}.gif” class=”iteration” />底部的文章可以这样:<img src=”../images/foot_{$smarty.foreach.nav_bottom_list.iteration}.jpg” class=”iteration” />
一月 20th, 2010 in
ECSHOP
I’m not good at ecshop , now I want to learn it.
Thanks !
我正得用着这个功能!现在正用着呢!