Alexandre Brach
Alexandre Brach

Reputation: 325

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) ?

Upvotes: 0

Views: 119

Answers (2)

Alexandre Brach
Alexandre Brach

Reputation: 325

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'); ?>

Upvotes: 1

Remko
Remko

Reputation: 958

Without knowing what your code looks like a common way to do this using Zend Framework views would be:

/paginatorViewscript.phtml

/* 
    Paginator script content 
*/

Your catalog page

<?=$this->render('paginatorViewscript.phtml')?>
/* 
    various catalog content 
*/
<?=$this->render('paginatorViewscript.phtml')?>

That way the script is shown twice (at top and bottom). You explicitly say you don't want to do this without external viewscript but this is the way to do this.

Maybe you could show why you don't want to use external viewscript?

Upvotes: 0

Related Questions