Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

smarty section loop

Tags:

php

smarty

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.

like image 943
seoppc Avatar asked Jan 19 '12 09:01

seoppc


1 Answers

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}
like image 63
xpapad Avatar answered Sep 18 '22 20:09

xpapad