|
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 |
mensi Smarty n00b
Joined: 29 Jun 2004 Posts: 4 Location: Switzerland -> Zug
|
Posted: Tue Jun 29, 2004 12:59 am Post subject: foreach and php5 iterators problem & solution |
|
|
I noticed that the current parsing of the {foreach} function casts the from parameter to an array so that it's impossible to use php5's iterators on objects.
A quick and perhaps dirty workaround for this is to change Smarty_Compiler.class.php:1168
from:
[php:1:bad303cb1b]$output .= "if (count(\$_from = (array)$from)):\n";[/php:1:bad303cb1b]
to [php:1:bad303cb1b]$output .= "if (is_object(\$_from = $from) || count(\$_from = (array)$from)):\n";[/php:1:bad303cb1b]
that will fix it only if you don't use the name= attribute as it needs the total count of items determined by count(), but I think you won't need that in connection with iterators...
would be nice if you could take care of this in the next release... |
|
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
|