我试图在list.phtml
文件中使用$this->getChildHtml()
在app/design/frontend/[custom]/[theme]/template/catalog/product
处插入div
。
在做<?php var_dump($this->getChildHtml('odoo'))?>
我得到string(0) ""
我在app/code/local/[Company]/[Module]
创建一个模块并创建了3210文件:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Company_Module>
<version>1.0.0</version>
</Company_Module>
</modules>
<frontend>
<rwd>
<company>
<layout>
<odoo>
<file>odoo.xml</file>
</odoo>
</layout>
</company>
</rwd>
</frontend>
</config>
然后,里面app/design/frontend/[custom]/[theme]/layout/odoo
:
<?xml version="1.0"?>
<layout version="0.1.0">
<reference name="content">
<block type="core/template" name="odoo" template="catalog/product/odoo.phtml" as="odoo" />
</reference>
</layout>
的odoo.phtml
代码:
<div>Hello world</div>
内list.phtml
<?php var_dump($this->getChildHtml('odoo'))?>
我已清除缓存,并手动删除的full_page_cache
内容,但我认为我做somethign错误的。我对Magento没有多少经验,只是编辑前端的mostry,所以我在这里有点迷路。
你可以var_dump高一级?看起来'$ this'的getChildHtml'属性没有'odoo'标签。 –
var_dump($ this) –
@phillipstack结果是一个空白页。看起来它产生了一个恐惧,但看着system.log,没有错误。 – aerojun