Search code examples
zend-frameworkzend-view

Zend View : How to use an output multiple times in the same view script?


I'm working on a page which show a list of articles of a catalog, with a pagination (I don't use Zend_Paginator)

The pagination bloc is ok, but I would render it multiple times (at the top and at the bottom of the list)

Inside the view script, is there a way to capture the output, and render it twice without using any external view script (which will be executed two times) ?


Solution

  • Placeholder is the solution, it capture once, and the output can be used multiple times :

    <?  $this->placeholder('foo')->captureStart(); ?>
    My script to make pagination...
    <? $this->placeholder('foo')->captureEnd() ?>
    
    <!-- used one time -->
    <?= $this->placeholder('foo'); ?>
    Items to display
    <!-- used a second time -->
    <?= $this->placeholder('foo'); ?>