javascript - Counter in smarty -
i assign values variable depending on counter's value inside each loop. if counter=1, assign value 'a', if counter not 1, assign value 'b'.
this how far have gotten code breaking once add conditions , counter change...
[{foreach from=$orderarticles item="currorderarticle"}] [{if $counter == 1}] products_info.push(["transaction_id='a'"]); [{assign var="counter" value=2}] [{else}] products_info.push(["transaction_id='b'"]); [{/if}] [{/foreach}]
smarty has iteration counter foreach loops
[{foreach $orderarticles $currorderarticle}] [{if $currorderarticle@iteration == 1}] ... ... [{else}] ... else ... [{/if}] [{/foreach}]
read more in smarty documentation foreach
Comments
Post a Comment