0

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

Alexandre Brach
  • 325
  • 2
  • 12

2 Answers2

1

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'); ?>
Alexandre Brach
  • 325
  • 2
  • 12
  • Nice, although i'm quite experienced with zend framework didn't knew about placeholders (probably because I never needed them so far). Keep that in mind. I have no time to test this with a benchmark but my guess would be that my solution (rendering twice) and your solution (placeholders) in a regular situation would perform near to equal. – Remko Aug 08 '13 at 06:59
0

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?

Remko
  • 968
  • 6
  • 19
  • The pagination script will be used only in this view script. So I prefer to keep this portion of html inside in order to avoid multiplication of phtml file in the project. The other reason is for performance : in your code, the view script will be executed twice, but only one execution is needed while I can use the output twice – Alexandre Brach Aug 07 '13 at 22:00