Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Registered object methods and arrays

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


Joined: 20 Nov 2009
Posts: 4

PostPosted: Fri Nov 20, 2009 6:43 pm    Post subject: Registered object methods and arrays Reply with quote

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
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Nov 20, 2009 7:48 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
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