Traversing objects from within a template

From: Date: Wed, 07 Jul 2004 11:31:25 +0000
Subject: Traversing objects from within a template
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11534@lists.php.net to get a copy of this message
I want to pass an object which is a composite of objects to my smarty template and be able to be access the nested object. For example: {$gallery->getPicture()->getTitle()} A simplified version of my object is as such: class SVGallery { var $_picture; function SVGallery(&$picture) {
    $this->setPicture($picture);
} function setPicture(&$picture) { $this->_picture = &$picture; } function &getPicture() { return $this->_picture; } } My php does the following: $smarty->assign_by_ref('gallery',$oGallery); The smarty debug output shows the nested objects fine, I just can't access them using the template syntax. I've tried assigning the object to a template var and running the method, but that does not work either. I've found this same question on the FAQ with no answer: http://smarty.incutio.com/?page=SmartyFrequentlyAskedQuestions#template-17 Any ideas aside from converting all my objects into nested associative arrays, which, although it would reduce coupling between model and view, I don't particularly need in this situation. -- tim http://www.toolmantim.com

« previous php.smarty.general (#11534) next »