0

I'm trying to add, the top links and store switcher, to the mobile menu. In header_type3.phtml, I can see it's calling store_switcher and topLinks blocks. I tried to call them from mobilemenu.phtml file, but it's not showing up. What am I missing here?

Here is the block from page.xml

<block type="page/template_links" name="top.links" as="topLinks" template="page/template/links.phtml"/>
<block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>

and mobilemenu.phtml

<div class="mobile-nav side-block container">
<div class="menu-all-pages-container">
    <ul class="menu">
        <?php echo $menuHelper->getMobileMenuContent($only_categories); ?>
    </ul><?php echo $this->getChildHtml('store_switcher') ?><?php echo $this->getChildHtml('topLinks') ?>
</div>

Hi Padhiyar, you gave me a good hint and I found the correct file to work in. I was using the wrong file and found the right one, after you asked for the layout file. On the other hand, I found another problem that I hope you can help me with.

As it is now, I have these top links in the header. Blog, Shops and contacts, About us, Contact and Log in. The layout file that specifies mobilemenu.phtml has this code

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <block type="core/template" name="sticky_header">
                <action method="setTemplate" ifconfig="porto_settings/header/sticky_header"><template>page/html/sticky_header.phtml</template></action>
            </block>
        </reference>
        <block type="megamenu/toggle"></block>
        <reference name="header">
            <block type="core/template" name="mobile.nav">
                <action method="setTemplate" ifconfig="porto_settings/general/disable_responsive" condition="0"><template>smartwave/megamenu/html/mobilemenu.phtml</template></action>                
            </block>
        </reference>
    </default>    
</layout>

and I added these two blocks, to call the store switcher and top links

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <block type="core/template" name="sticky_header">
                <action method="setTemplate" ifconfig="porto_settings/header/sticky_header"><template>page/html/sticky_header.phtml</template></action>
            </block>
        </reference>
        <block type="megamenu/toggle"></block>
        <reference name="header">
            <block type="core/template" name="mobile.nav">
                <action method="setTemplate" ifconfig="porto_settings/general/disable_responsive" condition="0"><template>smartwave/megamenu/html/mobilemenu.phtml</template></action>
                <block type="page/template_links" name="top.links" as="topLinks" template="page/template/links.phtml"/>
                <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
            </block>
        </reference>
    </default>    
</layout>

and here is the updated mobilemenu.phtml

<?php $menuHelper = Mage::helper('megamenu'); ?>
<?php $only_categories = $this->getOnlyCategories(); ?>
<div class="mobile-nav side-block container">
    <div class="menu-all-pages-container">
        <?php echo $this->getChildHtml('store_switcher') ?>
        <ul class="menu"><?php echo $menuHelper->getMobileMenuContent($only_categories); ?></ul>
        <?php echo $this->getChildHtml('topLinks') ?>
    </div>
</div>
<div class="mobile-nav-overlay close-mobile-nav"></div>

Now, the store switcher is added to mobile menu, and still exists in top header. It adds Shops and contacts, About us, Contact and Log in, to the mobile menu, but leaves out Blog and somehow, it thinks that I'm logged in, so "My account" is also there.

The blog is an extension, so I'm guessing, I have to call that block too, but why does it think that I'm logged in why is it removing the links from the header. I'd like to have them both on the header and in the mobile menu.

  • I need your layout file where you have spcefied mobilemenu.phtml – padhiyar gaurang Aug 30 '17 at 13:47
  • I updated the initial question, with some new findings and problem – Davallen Aug 31 '17 at 11:15
  • I have just notice your updated answer, giving you answer tommorow leaving for home. – padhiyar gaurang Aug 31 '17 at 14:39
  • Thank you Padhiyar, looking forward to seeing your answer – Davallen Sep 1 '17 at 8:25
  • Hello buddy, magento has some policy. If you give same alias or name to two blocks , the last block with sam alias render (override the first one). I am thinking that your block same alias may be. Please update them uniquely. This can resolve the issue may be. – padhiyar gaurang Sep 1 '17 at 8:49
0

Please update the code and try this one where your mobilemenu.phtml added.

    <?xml version="1.0"?>
    <layout version="0.1.0">
        <default>
            <reference name="head">
                <block type="core/template" name="sticky_header">
                    <action method="setTemplate" ifconfig="porto_settings/header/sticky_header"><template>page/html/sticky_header.phtml</template></action>
                </block>
            </reference>
            <block type="megamenu/toggle"></block>
            <reference name="header">
                <block type="core/template" ifconfig="porto_settings/general/disable_responsive"  name="mobile.nav" condition="0" template="smartwave/megamenu/html/mobilemenu.phtml">
                    <block type="page/template_links" name="top.links" as="topLinks" template="page/template/links.phtml" />
                    <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml" />
                </block>
            </reference>
        </default>    
    </layout>
  • It didn't work. Are you sure the blocks can use the same alias and name? Like you suggested earlier? In this example, they are called the same as in page.xml – Davallen Sep 1 '17 at 11:05
  • Your solution lead me to a solution that worked. Found the solution here stackoverflow.com/a/28224458/1872505 which suggests to reference it. So I updated the xml file which is rendering mobilemenu.phtml and put <reference name="mobile.nav"> <action method="insert"> <block_name_to_insert>top.links</block_name_to_insert> <sort_relative_to_other_childname/> <sort_before_or_after/> <alias>topLinks</alias> </action> </reference> – Davallen Sep 1 '17 at 11:37
  • Always happy to help. @Davallen. – padhiyar gaurang Sep 1 '17 at 11:39

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.