|
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 |
meze Smarty n00b
Joined: 20 Nov 2009 Posts: 4
|
Posted: Fri Nov 20, 2009 6:43 pm Post subject: Registered object methods and arrays |
|
|
i have smarty3b3 and a registered object. the object has a method that returns an array, but smarty compiles object function calls as "echo ...mymethod()..;" so when i do "{foreach {obj->getarray} as $v}{$v}{/foreach}", i get string "Array". How do i fix it? or is it a bug? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Nov 20, 2009 7:48 pm Post subject: |
|
|
Smarty normally outputs function results to the display. For instance:
{foo}
Would display the results of the foo function without any sort of "echo" command in the template. Therefore, {obj->foo} would also output the result. If you want the output assigned, or iteratable, I'd recommend using a variable instead:
{foreach $obj->getarray as $v} |
|
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
|