I want to load the topLinks on a page and use this code:

echo $this->getChildHtml('topLinks');

But this does not work. How can I load the topLinks?


1 Answer 1


Your question is a little too generic. What block are you working from in your template example? In a default Magento 1.x CE installation, that block is defined in page.xml as part of the header block declaration:

# File: app/design/frontend/base/default/layout/page.xml
<block type="page/html_header" name="header" as="header">
    <block type="page/template_links" name="top.links" as="topLinks"/>
    <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
    <block type="core/text_list" name="top.menu" as="topMenu" translate="label">
        <label>Navigation Bar</label>
        <block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>

So unless your block is a direct child of header, you can't access it; at least not by its block alias (as="topLinks")

If your block/template in question is not part of the header block, you can access it by its global name instead from the layout instance:

echo $this->getLayout()->getBlock('top.links')->toHtml();

Depending on where you're doing this, you should get your desired result.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.