Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

smarty for loop unrecognised tag

I just started using Smarty today so I may be doing this completely wrong, but I can't seem to find a solution to the problem. I'm trying to get a for loop to iterate 4 times, incrementing $i on each iteration. Pretty standard stuff.

According to the Smarty documentation, for loops should be of the following form:

{for $var=$start to $end}

My current loop statement is as follows:

{for $i=0 to 3}

But I am getting the following error at runtime:

Fatal error: Smarty error: [in ..views/landing/index.tpl line 69]: syntax error: unrecognized tag 'for' (Smarty_Compiler.class.php, line 590) in ../library/1.11/Smarty/Smarty.class.php on line 1093

The loop is on line 69 which is the line that the compiler is failing on. I've also shortened the urls in that error message for easier reading.

I'm not sure what I'm doing wrong here. I've tried googling various parts of the error message, but to no avail.

Thanks for your time.

like image 706
Kaizen9001 Avatar asked Jan 23 '13 13:01

Kaizen9001


1 Answers

Apologies. Just realised our server is running Smarty V2. For loops weren't introduced until V3. If anyone else is having this problem and are, like me, unable to upgrade look up the {Section} and {foreach} tags. They are available in V2 and might be able to do what you need them to.

like image 118
Kaizen9001 Avatar answered Oct 16 '22 12:10

Kaizen9001