Zend View:如何在同一个视图脚本中多次使用输出?

时间:2013-08-07 13:27:48

标签: zend-framework zend-view

我正在制作一个页面,其中显示了目录的文章列表,并且有一个分页(我不使用Zend_Paginator)

分页集合没问题,但我会多次渲染(在列表的顶部和底部)

在视图脚本中,有没有办法捕获输出,并在不使用任何外部视图脚本(将执行两次)的情况下渲染两次?

2 个答案:

答案 0 :(得分:1)

占位符是解决方案,它捕获一次,输出可以多次使用:

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

答案 1 :(得分:0)

不知道你的代码是什么样的,使用Zend Framework视图的常用方法是:

<强> /paginatorViewscript.phtml

/* 
    Paginator script content 
*/

您的目录页

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

这样,脚本会显示两次(顶部和底部)。你明确表示你不想在没有外部视图的情况下这样做,但这是做到这一点的方法。

也许您可以说明为什么您不想使用外部视图?

相关问题