Partials are handy because they allow you to dissect html code and template logic into smaller reusable bits. PartialLoops allow you to loop through objects and arrays in an efficient manner and in a seperate variable scope.
Sometimes it is neccessary to access variables and their values from the view object's scope that the partial was called from.
This can be done quite easily from the by calling the partialLoop() or partial() (or another view helper's) method from the partial template and then accessing the view object from that.
// in the view template: $this->bla = 'blabla'; //value we will access echo $this->partialLoop('imageviews/thumbnails.phtml',$this->searchResults);
//in the partialLoop template: <?php echo $this->partialLoop()->view->bla // echo's blabla ?>
//You can ofcourse also retrieve the view in the partialLoop as anywhere like this: $view = Zend_Layout::getMvcInstance()->getView();
Both methods would probably impact performance with large sets of data so I'm still looking for a better way.
You can also assign variables to the layout object from your view and then access them in the partialLoop like so:
//To assign values to your layout object before the partial $this->layout()->test = 'foo'; //and retrieve them using layout() inside the partialLoop template: echo $this->layout()->test; // echoes 'foo'