Reputation: 12957
I'm using smarty template engine version 2.6.18 for my web site. I've following code for printing 1 to 4 numbers. But I'm getting error as:
Fatal error: Smarty error: [in view-item-request.tpl line 67]: syntax error: unrecognized tag 'for'
My code is as follows:
{for $foo = 1 to 40}
<p>{$foo}</p>
{/for}
Can someone please help me in resolving this issue? Thanks in advance.
Upvotes: 1
Views: 4035
Reputation: 504
The {for} loop is a Smarty 3 supported syntax. For Smarty 2, you can use {section}, and use iteration instead of index to view the values as 1-40 instead of 0-39.
{section name=foo loop=40}
<p>{$smarty.section.foo.iteration}</p>
{/section}
Upvotes: 4
Reputation: 111839
Smarty has it's own syntax. There is no for
loop butforeach
and section
.
You can achieve what you want using section this way:
{section name=foo start=1 loop= 40}
<p>{$smarty.section.foo.index}</p>
{/section}
Upvotes: 2