开发者

Smarty foreach index value issue

In smarty foreach loop,{$smarty.foreach.foo.iteration} is working fine,but {$smarty.foreach.foo.index} is not working. I couldn't figure out the issue.

Please any one help me!!!

Example:

code:

{foreach name=navLoo开发者_开发百科p from=$links_res_cat_detailsObj item="links_res"}
{$smarty.foreach.navLoop.iteration}
{/if}

output:123 but when i am trying to printout the index value, i am geting nothing Example

code:

{foreach name=navLoop from=$links_res_cat_detailsObj item="links_res"}
{$smarty.foreach.navLoop.index}
{/if}

output:


This is really strange. It looks like you are using it correctly (see the manual) I've compiled a test for you, and this works fine. Could it be some typo, or a problem in the data?

    <ul>
    {foreach item=item from=$myVar name=test}
        <li>{$smarty.foreach.test.iteration} - {$smarty.foreach.test.index}</li>
    {/foreach}
    </ul>

The only thing strange about your code is the " around your item, but that could not be the problem, could it? I'd run it with above thest (so both the iteration and the index), to make sure one works and the other doesn't... Because that's just weird :)


The smarty template system implemented in phpfox uses custom functionality and not everything is implemented. Though you should try using the $phpfox. instead of $smarty.

The following will work (tested on v3.6):

{foreach item=item from=$myVar name=test}
    <li>{$phpfox.foreach.test.iteration} - {$phpfox.foreach.test.index}</li>
{/foreach}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜