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” />

Comments (2)

alex十一月 22nd, 2010 at 2:28 下午

I’m not good at ecshop , now I want to learn it.
Thanks !

西式瓦十二月 9th, 2011 at 4:09 下午

我正得用着这个功能!现在正用着呢!

Leave a comment

Your comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word