我在从foreach的最后一个选项中添加一个类时遇到了麻烦,它出于某种原因重复它有什么想法吗?
{if $subcategories}
<div class="subcategories">
{if $subcategories|@count < 6}
<ul>
{/if}
{foreach from=$splitted_subcategories item="ssubcateg"}
{if $subcategories|count >= 6}
<div class="subcategories">
<ul>
{/if}
{foreach from=$ssubcateg item=category name="ssubcateg"}
{if $category.category_id}<li{if $smarty.foreach.ssubcateg.last} class="last"{/if}><a href="{"categories.view?category_id=`$category.category_id`"|fn_url}" class="strong">{$category.category}</a></li>{/if}
{/foreach}
{if $subcategories|count >= 6}
</ul>
</div>
{/if}
{/foreach}
{if $subcategories|count < 6}
</ul>
{/if}
</div>
{/if}
输出:似乎在重复?如果有 6 个结果是添加一个 class="last" 但中间结果如第三个结果?
<ul>
<li class="last"><a class="strong" href="#">Link</a></li>
<li><a class="strong" href="#">Link</a></li>
<li class="last"><a class="strong" href="#">Link</a></li>
<li><a class="strong" href="#">Link</a></li>
</ul>