从视图脚本替换 ZEND 占位符内容


replacing zend placeholder contents from the view script

我像这样初始化我的占位符:

默认.phtml(布局文件(

<?php $this->placeholder('hero')->captureStart(); ?>
<div class="primary">
  <h1>Foo bar!</h1>
</div>
<?php $this->placeholder('hero')->captureEnd(); ?>
<?php echo $this->placeholder('hero'); ?>

index.phtml (查看脚本文件(

<?php $this->placeholder('hero')->captureStart(); ?>
<div class="primary">
  <h1>Bar Baz!</h1>
</div>
<?php $this->placeholder('hero')->captureEnd(); ?>
<?php echo $this->placeholder('hero'); ?>

输出:在我的输出中,我最终得到了两个标题。我只想让巴尔巴兹显示。

巴兹!

噗噗!

如何替换/覆盖占位符的视图脚本中的内容?

>captureStart()的默认设置(检查示例 #13(append尝试将其设置为 set

<?php $this->placeholder('hero')->captureStart('SET'); ?>
<div class="primary">
  <h1>Bar Baz!</h1>
</div>
<?php $this->placeholder('hero')->captureEnd(); ?>
<?php echo $this->placeholder('hero'); ?>