基本上这段代码给了我< li> 1 2 3 4< / li> < li> 1 2 3 4< / li> < li> 1 2< / li>。所以基本上最后我需要将3和4放在不同的结果中,例如< li> 1 2空空< / li> - 因为每个人应该总共有4个结果< li> / li>,它很棘手,因为循环提供了尽可能多的东西,有时会少一些:)。
<ul>
{section name=attribs loop=$AccountHistory}
{if $smarty.section.attribs.index % 4 == 0 or $smarty.section.attribs.first}
<li>
{/if}
{$smarty.section.iteration}
{if $smarty.section.attribs.index % 4 == 3 or $smarty.section.attribs.last}
</li>
{/if}
{/section}
</ul>
答案 0 :(得分:1)
也许是这样的东西进入循环?
{if $smarty.section.attribs.last && ($smarty.section.attribs.index % 4) >0}
{section name=tmp loop=(4-($smarty.section.attribs.index % 4)) start=(( $smarty.section.attribs.index % 4) + 1)}
{$smarty.section.tmp.index}
{/section}
{/if}