Skip to content

Instantly share code, notes, and snippets.

@manticorp
Last active December 15, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manticorp/5183012 to your computer and use it in GitHub Desktop.
Save manticorp/5183012 to your computer and use it in GitHub Desktop.
Passing a Doctrine entity object to a partial or a partial loop in Zend framework
//You can pass objects to partials, just pass them in an array:
$this->partial('mypartial.phtml', array('topic' => $topic'))
//The partial helper will take the keys of that array and create view vars out of them, so you can access it like this from within the partial:
<td><?= $this->topic->getDescription() ?></td>
//If you want to use objects with a partial loop, you can call setObjectKey() on the partialLoop helper and pass in an array of objects:
$this->partialLoop()->setObjectKey('topic')->partialLoop('mypartial.phtml', $topics)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment