Magento: getChildHtml() not working

Do you want to use

echo $this->getChildHtml("mychild")

in your template and it doesn’t work? Do you have in your layout xml file something like:

<some_controller_action>
    <block type="some/block">
        <block type="other/block" name="mychild">
    </block>
>/some_controller_action>

Yes, this is really annoying. Add a name attribute to your some/block block, and it will instantly work! So the correct layout xml will look like:

 

<some_controller_action>
    <block type="some/block" name="somename">
        <block type="other/block" name="mychild">
    </block>
>/some_controller_action>

That's all folks!

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.