Magento 1.9:向标题添加自定义块

时间:2014-08-26 10:02:44

标签: magento

我在local.xml中有这个。

    <reference name="header">
        <block type="core/template" name="wc-customheadblock" template="wc-customheadblock.phtml" />
    </reference>

在wc-customheadblock.phtml里面我有:

<div style="height:100px; background-color:green">

<h1>This is the wc custom head block</h1>

</div>

但是这个块没有出现在标题中。我已经尝试了相同的侧边栏(通过更改xml引用名称),它工作得很好。为什么这对标题不起作用?

该网站声称可以使用local.xml为标题添加块! http://www.classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout

1 个答案:

答案 0 :(得分:3)

转到header.phtml文件(app / design / frontend / package / theme / page / html / header.phtml)并放置以下行之一:

<?php echo $this->getChildHtml(); ?>

<?php echo $this->getChildHtml('wc-customheadblock'); ?>

最有可能的标题默认情况下不会渲染子块,因为它会导致一些模板崩溃。在侧边栏上,最后可以轻松添加额外的孩子。

相关问题