-
January 20, 2024, 06:16 AM
#1
Senior Member
Can you use {for} tag to do a simple loop within templates?
Can you use the {for} smarty tag in a template to do a simple loop like
{for $itemnumber=1 to 16}
<li>{$itemnumber}</li>
{/for}
I tried it and got a syntax error: unrecognized tag 'for'
I don't have much experience with smarty, so I thought I'd ask to see if this is possible within a template before looking further to see where my error may be. Thanks!
-
January 20, 2024, 09:09 AM
#2
Flynax developer
You need to use foreach operator like:
{foreach from=Object item='element_name' key='key_name' name='loop_name'}
{/foreach}
see full info about smarty code here: https://www.smarty.net/docsv2/en/