Fun Times with Partial Loops in Zend Framework
While working with the Zend Framework and partial loops, I ran into a few issues. One was not getting the data to load, which was easily solved after looking at partials documentation. Make sure you set the object key in the controller for the partial loop. The other issue of trying to pass local variables into the partial loop took time to see there was really no current answer without extending or creating a new helper, or the evil global.
PHP
// in the action method
global $otherVariable;
$otherVariable = "should be the same through each iteration";
$this->view->partialLoop()->setObjectKey('model');
$this->view->paginator = Zend_Paginator::factory($array); //etc
// in the view
<?= $this->partialLoop('path/to/_partial.phtml', $this->paginator) ?>
// in the _partial.phtml
<?php
$model = $this->model
global $otherVariable; // just seems so hackish to have to do this.
?>
I have already added a task to Midori PHP to extend the Partial Loop Helper to overcome the lack of the ability to pass in local variables to the partial loop.