|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Wed Nov 21, 2012 3:07 pm Post subject: smarty 2 and smarty 2 iterator compatibility |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Nov 21, 2012 3:44 pm Post subject: |
|
|
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 |
|
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Wed Nov 21, 2012 3:58 pm Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Nov 21, 2012 8:22 pm Post subject: |
|
|
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 |
|
|
|
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
|