smarty section loop

seoppc picture seoppc · Jan 19, 2012 · Viewed 14.7k times · Source

I am trying to get a loop for following...

{$product.min_val} //2
{$product.max_val} //8

and i am trying following...

{section name=val start=$product.min_val loop=$product.max_val step=0}
<p id="{$smarty.section.val.index}">{$smarty.section.val.index}</p>
{/section}

it prints following...

<p id="2">2</p>
<p id="3">3</p>
<p id="4">4</p>
<p id="5">5</p>
<p id="6">6</p>
<p id="7">7</p>

You might have noticed that its missing <p id="8">8</p> according to {$product.max_val} thanks.

Answer

xpapad picture xpapad · Jan 19, 2012

Loop is the number of times the section will loop, so you need:

{section name=val start=$product.min_val loop=$product.max_val+1}
<p id="{$smarty.section.val.index}">{$smarty.section.val.index}</p>
{/section}