Search code examples
phpxmlmagentolayouttemplate-engine

Magento duplicate block output in xml layout


i'm creating a menu in Magento in this way:

<block type="page/template_links" name="footer_links2" as="footer_links2" template="page/template/links.phtml">
    <action method="setTitle"><title>Main menu</title></action>
    <action method="addLink" translate="label title" module="catalogsearch">
        <label>About us</label>
        <url helper="cms/page/getPageUrl"><pageId>3</pageId></url>
        <title>About us</title>
    </action>
    <action method="addLink" translate="label title" module="catalogsearch">
        <label>Contact us</label>
        <url helper="cms/page/getPageUrl"><pageId>4</pageId></url>
        <title>Contact us</title>
    </action>
    <!-- Other links here... -->
</block>

and it works, but i want that the same menu appears in a different part of the page too with the same content. Is there a way to duplicate the output of that block so that i can show it without duplicating the code?


Solution

  • I guess you would call your block in the template using:

    $this->getChildHtml('footer_links2');
    

    If so, you can place the same line of code in the other place you want the menu. I.e. you can place the code both in header and footer.

    Be careful though to have the "same parent". If the block is declared in xml inside the header block, you cannot call it inside the footer in the template.