我是smarty概念的新手。我在我的tpl页面中使用了段循环来显示用户数据,在这个页面中我需要段数。Smarty loop count
例如:
{section name=i loop=$getFriends start=0 step=1}
{/section}
我需要检查部计数数组值($ getFriends)以显示用户的一些消息。所以请指导我如何使章节计数。
我是smarty概念的新手。我在我的tpl页面中使用了段循环来显示用户数据,在这个页面中我需要段数。Smarty loop count
例如:
{section name=i loop=$getFriends start=0 step=1}
{/section}
我需要检查部计数数组值($ getFriends)以显示用户的一些消息。所以请指导我如何使章节计数。
'count'是否指循环的当前索引?
如果是这样,你可以使用这个
{section name=customer loop=$custid}
{$smarty.section.customer.index} id: {$custid[customer]}<br />
{/section}
http://www.smarty.net/docsv2/en/language.function.section.tpl#section.property.index
尝试{}柜台http://www.smarty.net/docsv2/en/language.function.counter.tpl Exapmle:
{counter start=0 print=false name=bla}
{section name=i loop=$getFriends start=0 step=1}
{counter}
{/section}
{assign var=val value=0}
{section name=i loop=$data}
{assign var=val value=$val+1}
{/section}
我从smarty.net得到了同样的想法。谢谢 – Anandhan 2011-04-01 09:08:37
对'foreach'循环可以做同样的事情'$ smart.foreach.customer.total' – Htbaa 2011-04-01 09:30:57