English 中文(简体)
婚前 for不正确工作?
原标题:smarty foreach last not working correctly?

在最后一种选择中增加一个班子,从原样子,出于某种原因重复这个班子?

{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}

output: seems to be repeating? and if there are 6 results is adds one class="last" but the middle result as in 3rd result?

<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>
最佳回答

你的最后一个项目是重复的,因为你在“内 lo”中重新检查“仇恨”。 你再次忽视了内院本身。 审判:

{foreach from=$splitted_subcategories item="ssubcateg" name="outer"}
  {foreach from=$ssubcateg item=category name="ssubcateg"}
    {if $smarty.foreach.outer.last && $smarty.foreach.ssubcateg.last}
      …
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签