Foreach objects in smarty

Posted by shadow_of__soul | Posted in Uncategorized | Posted on 05-03-2010

0

Hi,

recently i changed how a REST API sent the info from xml to JSON, that mean that now the arrays was converted into objects after the json_decode(). don’t was too much problem till i see that my smarty templates don’t worked anymore :(

the change of each file don’t was an option and the convert from objects to arrays is wasting resources in nothing, so i made a hack in the smarty main class :D

basically in the file Smarty_Compiler.php at line numero 1203 i added this if():

if(is_object($from)){
$output .= “\$_from = $from;”;
$output .= “foreach(\$_from as $key_part=>$item){“;
}else{

and in the else, you wrap all the other code to parse arrays :D

now the foreach will parse objects and arrays :D

i hope it helps.

Regards,

Shadow.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Click here to lend your support to: Funding for Ipsilon Developments and make a donation at www.pledgie.com !

Related Post

Write a comment