我得到第一个这样的项目:
{foreach $sArticle.sBlockPrices as $blockPrice}
{if $blockPrice@first}
First element
{else}
...
{/if}
{/foreach}
如何获得第二/第三项?
答案 0 :(得分:0)
使用此处引用的foreach的index属性:http://www.smarty.net/docsv2/en/language.function.foreach.tpl
尝试这样的事情:
{foreach name=$sArticle.sBlockPrices item=$blockPrice name=blockPrices}
{if $smarty.foreach.blockPrices.index == 2}
...
{/if}
{/foreach}