Вопрос

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.

Это было полезно?

Решение

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>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top