I'm not 100% positive on this, but from what I can tell by looking at the source and documentation is that standard behavior for rendering a partial is that values are passed into it in the form of an associative array. This allows the values to be bound to variables using array keys.
echo $this->partial('partial.phtml', array ('person' => 'joe');
// in my partial..
<h1><?php echo $this->person; ?></h1> //<h1>Joe</h1>
If you pass an object as the third parameter, (ie, partial('partial.phtml', $myobject);
), Zend_View_Partial will automatically serialize that object in an associative array, either by a custom implementation of toArray()
or it will just grab the public properties via get_object_vars()
.
However, if you want to pass the whole object, as an object, you need to set the array key that gets transformed into a variable for the partial to reference.
$this->partial()->setObjectKey('myobject');
echo $this->partial('partial.phtml', $myobject);
What benefits this approach has over partial('partial.phtml', array( 'myobject' => $myobject)
, I'm not sure. Or I could be interpreting the documentation wrong.