【发布时间】:2015-05-11 16:29:04
【问题描述】:
在 Magento 1.9 中,我想向主页添加一个自定义块,但没有任何反应。我有这些文件:
app/design/frontend/[mytheme]/default/layout/local.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="root">
<block type="core/text_list" name="customblock" as="customblock" translate="label">
<label>Custom Block</label>
</block>
</reference>
<reference name="customblockreference">
<block type="core/template" name="customblock" template="customblock.phtml" />
</reference>
</default>
</layout>
在主页.phtml中
<?php echo $this->getChildHtml('customblock') ?>
在 app/design/frontend/[mytheme]/default/template/customblock.phtml
<h1>test</h1>
我哪里做错了?
【问题讨论】:
-
您必须将通过
homepage.phtml显示的块的名称放在参考节点的名称属性中。但是由于homepage.phtml不是来自 Magento 的股票,如果您至少不向我们提供声明此父块的布局,我们将无能为力。