Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
smarty 2 and smarty 2 iterator compatibility

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Wed Nov 21, 2012 3:07 pm    Post subject: smarty 2 and smarty 2 iterator compatibility Reply with quote

Hi,
I'm using smarty 2 in my system. But now i'm changing it to smarty 3 step by step. so, i change templates for smarty 3 and grok for smarty 2 campability.
in many places i've code like this:
Code:

{foreach name=profiles from=$profiles item="item"}
{if $smarty.foreach.profiles.iteration%3==1}
...


and smarty 3 can not parse this.

by the way, it is not template file. it is string resourse from db.

I don't want to change it to new foreach and interator syntax, because smarty 2 then can not parse that...

Any idea how can i do this?

Thanks.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7256
Location: Lincoln Nebraska, USA

PostPosted: Wed Nov 21, 2012 3:44 pm    Post subject: Reply with quote

Not sure if this helps, but smarty 2 and 3 support this syntax:

{if $smarty.foreach.profiles.iteration is div by 3}

You didn't specify exactly what part of the syntax Smarty 3 is bailing on. It sound like it could be a bug with %3 syntax.
Back to top
View user's profile Send private message Visit poster's website
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Wed Nov 21, 2012 3:58 pm    Post subject: Reply with quote

it's strange, but in _templates_ that code works good.
but when i use register_resource and then fetch string content, i get such error:

Code:
Fatal error: Cannot use string offset as an array in en_AU^8166aa73cad97c95d6eddf8c0484ca355e854eb6.content.d19dac92a6986ad0e21744ee096ee5f8.php on line 247


247 is
Code:
$_smarty_tpl->tpl_vars['smarty']->value['foreach']['profiles']['iteration']=0;
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4589
Location: Hamburg / Germany

PostPosted: Wed Nov 21, 2012 8:22 pm    Post subject: Reply with quote

This is really strange as it does work when you use a template from file system.

The code of line 247 looks correct.

Which version of PHP have you installed?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP