How to use Zend Framework's Partial Loop with Objects -
i quite confused how use partialloop
currently use
foreach ($childrentodos $childtodo) { echo $this->partial('todos/_row.phtml', array('todo' => $childtodo)); } $childrentodos doctrine\orm\persistantcollection, $childtodo application\models\todo
i tried doing
echo $this->partialloop('todos/_row.phtml', $childrentodos) ->setobjectkey('application\models\todo'); but in partial when try access properties/functions of todo class, cant seem them ending either call undefined method zend_view::myfunction() when use $this->myfunction() in partial or if try $this->todo->getname() "call member function getname() on non-object". how use partialloops?
try this
echo $this->partialloop('todos/_row.phtml', $childrentodos) ->setobjectkey('object'); then in partial can access object this
$this->object object name of variable object assigned to
you can once in bootstrap or other initialization class if have access view object so
protected function initpartialloopobject() { $this->_view->partialloop()->setobjectkey('object'); $viewrenderer = zend_controller_action_helperbroker::getstatichelper('viewrenderer'); $viewrenderer->setview($this->_view); }
Comments
Post a Comment