0

I am messing with this problem for two days, i want my horizontal menu to appear on all pages except the homepage. my homepage shows both vertical and horizontal menu, however, i just want vertical menu to appear on the home page and horizontal menu to appear on all other pages. here is the code of

/app/design/frontend/my_package/my_theme/Magento_Theme/layout/default.xml <

 <referenceContainer name="page.top">
        <container name="top.container" as="topContainer" label="After Page Header Top" htmlTag="div" htmlClass="top-container"/>

        <block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/sections.phtml">
            <arguments>
                <argument name="group_name" xsi:type="string">navigation-sections</argument>
                <argument name="group_css" xsi:type="string">nav-sections</argument>
            </arguments>

            <block class="Magento\Framework\View\Element\Template" name="store.menu" group="navigation-sections" template="Magento_Theme::html/container.phtml">

                <block class="Magento\Theme\Block\Html\Topmenu" name="catalog.topnav" template="html/sidebarmenu.phtml" ttl="3600"/>
                <block class="Magento\Cms\Block\Block" name="main_menu">
                    <arguments>
                        <argument name="block_id" xsi:type="string">main_menu</argument>
                    </arguments>
                </block>

Can someone guide me what should I do so that the horizontal menu does not appear on the front-page but appear on all other pages?

I've asked this question two times before, and now I'm asking this for the third time. dear seniors and experienced fellows guide me. this is what i've tried on

/app/design/frontend/my_package/my_theme/Magento_Theme/page_layout/1column.xml <

code below:

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
   <referenceBlock name="main_menu" remove="true"/>
    <move element="catalog.leftnav" destination="sidebar.main" after="-"/>
    <referenceContainer name="columns">
        <container name="div.sidebar.main" htmlTag="div" htmlClass="sidebar-filter sidebar zoo-sidebar-main" before="main" htmlId="sidebar-without">
            <container name="sidebar.main" as="sidebar_main" label="Sidebar Main"/>
        </container>
    </referenceContainer>
   </refrenceBlock> 
</layout>

what am I doing wrong?

  • @piyush now magento is giving me "Please correct the XML data and try again. Element 'referenceBlock', attribute 'name': [facet 'pattern'] The value 'magento/main-menu' is not accepted by the pattern '[a-zA-Z0-9][a-zA-Z\d\-_\.]*'. Line: 2 Element 'referenceBlock', attribute 'name': 'magento/main-menu' is not a valid value of the atomic type 'elementNameType'. Line: 2" – Laiba Feb 23 '18 at 11:36
0

Go to admin panel, Select Content->Pages from Menu and edit your homepage.

Then on edit page Under Design tab add below code for Layout Update XML input

<referenceContainer name="page.top">
        <referenceBlock name="name_of_your_horizontal_menu_block" remove="true" />
</referenceContainer>

change reference block name with your horizontal menu block name

| improve this answer | |
  • magento is giving me the following error when i'm trying to save – Laiba Feb 23 '18 at 11:05
  • Please correct the XML data and try again. Element 'referenceBlock': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1 – Laiba Feb 23 '18 at 11:05
  • nothing changed piyush. is there some other way? – Laiba Feb 23 '18 at 11:12
  • this will work, you have to define proper name for both tags – Piyush Feb 23 '18 at 11:15
  • <referenceContainer name="page.top"> <referenceBlock name="main_menu" remove="true" /> </referenceContainer> i used this but still no change. – Laiba Feb 23 '18 at 11:15

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.