webstermobile
Fork me on GitHub
个人博客

SMARTY教程_在循环中获取一个会自动增加的数字

例如,我要修改页面底部的帮助部分,要求是 每一类帮助使用不同的样式。

本篇教程只是起到一个敲门砖的作用,其他细节还需要自己发挥。

<!-- {foreach from=$helps item=help_cat name=help_list} -->
                    <ul class="help{$smarty.foreach.help_list.iteration}">
                                <li class="title">{$help_cat.cat_name}</li>
         <!-- {foreach from=$help_cat.article item=item} -->
                                   <li><a href="{$item.url}" title="{$item.title|escape:html}">{$item.short_title}</a></li>
     <!-- {/foreach} -->
                        </ul>
         <!-- {/foreach} -->

{$smarty.foreach.help_list.iteration} 就是那个能自动增长的数字,是从1开始循环,每次加1。

posted @ 2014-04-15 16:13  wpindesign  阅读(373)  评论(0编辑  收藏  举报