我已经编辑了以下文件,将时事通讯移动到页脚而不是侧边栏
app/design/frontend/base/default/layout/newsletter.xml
我更改了以下代码:
<reference name="left">
<block type="newsletter/subscribe" name="left.newsletter" template="newsletter/subscribe.phtml"/>
</reference>
自:
<reference name="footer">
为什么我不需要添加
$this->getChildHtml('newsletter')
或类似于 footer.phtml?我不确定何时使用getChildHtml(),何时不使用。本文练习 #2 中的所有步骤都是必需的吗?
谢谢。
如果你看一下 page/html/footer.phtml
,这是页脚块的模板
<div class="footer-container">
<div class="footer">
<?php echo $this->getChildHtml() ?>
<p class="bugs"><?php echo $this->__('Help Us to Keep Magento Healthy') ?> - <a href="http://www.magentocommerce.com/bug-tracking" onclick="this.target='_blank'"><strong><?php echo $this->__('Report All Bugs') ?></strong></a> <?php echo $this->__('(ver. %s)', Mage::getVersion()) ?></p>
<address><?php echo $this->getCopyright() ?></address>
</div>
</div>
您可以看到他们使用以下 PHP 来输出子块
<?php echo $this->getChildHtml() ?>
当在没有参数的情况下调用getChildHtml
时,它将输出已添加的任何块。 这就是为什么您不需要包括自己的呼叫$this->getChildHtml('newsletter')