skywind skywind - 1 year ago 120
Smarty Question

How to check iteration in smarty?

How can I check the current iteration for foreach and do something?

{foreach $new_products as $product name=foo}
{if $smarty.foreach.foo.iteration=5}
Do it!
{/if}
{/foreach}


This always return not checked

Answer Source

I think you should do {if $smarty.foreach.foo.iteration == 5} (note the ==).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download