我编辑了以下文件,将新闻稿移到页脚而不是侧边栏

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()以及何时不使用。
所有的步骤都是必要的吗?
谢谢。

最佳答案

如果您查看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')

10-05 17:45