1

I have the following xml declaration.

        <reference name="header">
        <block type="usability/features" name="usability.features" as="usability_features" template=" client/usability/features.phtml" before="-">                
            <block type="usability/offcanvasmenu" name="usability.offcanvasmenu" as="usability_offcanvasmenu" template="client/usability/offcanvasmenu.phtml" before="-">
                 <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.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" as="topMenu" template="page/html/topmenu.phtml">
                    </block>  
                </block>
            </block>
        </block>
    </reference>

I have inside features.phtml

 <?php $this->getChildHtml('usability_offcanvasmenu');?>

This works as expected and offcanvasmenu.phtml contains the following

<div>
   <?php echo $this->getChildHtml('topSearch');?>
   <?php echo $this->getChildHtml('topMenu');?>
</div>

The above code displays the search bar however does not display the menu. A vague guess makes me think it might be something to do with topMenu being a structural block, still as far as I understand the layout system this should still be rendered.

It is possible that the include is unset somewhere else in the theme, however I think it is more likely I have missed a step due to my gaps in understanding.

  • which is the magento version ? – Rajeev K Tomy May 17 '16 at 12:09
  • 1.6.2 is the version I'm working with. However I don't think the xml api changed much since then? – Simmelulation May 17 '16 at 13:32
0

If you are using Magento version >= 1.9, then following code may work in your case.

<reference name="header">
    <block type="usability/features" name="usability.features" as="usability_features" template=" client/usability/features.phtml" before="-">        
        <block type="usability/offcanvasmenu" name="usability.offcanvasmenu" as="usability_offcanvasmenu" template="client/usability/offcanvasmenu.phtml" before="-">
            <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.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">
                    <block type="page/html_topmenu_renderer" name="catalog.topnav.renderer" template="page/html/topmenu/renderer.phtml"/>
                </block>
            </block>
        </block>
    </block>
</reference>

This is because from version 1.9 onwards, Magento uses a special menu renderer block to render topmenu which is Mage_Page_Block_Html_Topmenu_Renderer. You can see that, in my code this class is included inside the block Mage_Page_Block_Html_Topmenu.

0

hmm maybe try with it:

<?php echo $this->getChildHtml('topSearch');?>
<?php echo $this->getChildHtml('topMenu');?>

  • Thanks for the suggestion. You're correct that the return values of getChildHtml method require to be echoed, unfortunately this was a typo in my question. – Simmelulation May 17 '16 at 13:33
  • ok :) I notice that you set the same alias for your core/text_list block and your page/html_topmenu block . Try to remove alias on your page/html_topmenublock. When you make a die() in your topmenu.phtml what happens? – Sony May 17 '16 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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