我编辑了以下文件,将简报移到页脚而不是侧边栏
app/design/frontend/base/default/layout/newsletter.xml
Run Code Online (Sandbox Code Playgroud)
我更改了以下代码:
<reference name="left">
<block type="newsletter/subscribe" name="left.newsletter" template="newsletter/subscribe.phtml"/>
</reference>
Run Code Online (Sandbox Code Playgroud)
至:
<reference name="footer">
Run Code Online (Sandbox Code Playgroud)
为什么我不需要添加
$this->getChildHtml('newsletter')
Run Code Online (Sandbox Code Playgroud)
或类似于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>
Run Code Online (Sandbox Code Playgroud)
您可以看到他们已使用以下PHP输出子块
<?php echo $this->getChildHtml() ?>
Run Code Online (Sandbox Code Playgroud)
如果getChildHtml在没有参数的情况下调用它,它将输出已添加的任何块.这就是为什么你不需要包括你自己的电话$this->getChildHtml('newsletter')
| 归档时间: |
|
| 查看次数: |
4084 次 |
| 最近记录: |