aerojun aerojun - 2 months ago 15
PHP Question

$this->getChildHtml() returns empty string

I'm trying to insert a

div
inside the
list.phtml
file at
app/design/frontend/[custom]/[theme]/template/catalog/product
using
$this->getChildHtml()
.

When doing
<?php var_dump( $this->getChildHtml('odoo') )?>
i get
string(0) ""


I have created a module at
app/code/local/[Company]/[Module]
and created the
config.xml
file:

<?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>


Then, inside
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>


The code of
odoo.phtml
:

<div>Hello world</div>


Inside
list.phtml


<?php var_dump( $this->getChildHtml('odoo') )?>


I've cleared the cache and manually erased the
full_page_cache
contents but i think i'm doing somethign wrong. I have little experience with Magento, mostry just editing the frontend, so i'm a little lost here.

Answer

Solved.

Added <block type="core/template" name="odoo" template="catalog/product/odoo.phtml" as="odoo" /> to the page.xml layout.