1

I want to replace the top menu bar to the left side i have written this code in my theme default.xml

<body>
<referenceContainer name="sidebar.main">
<block class="Magento\Framework\View\Element\Template" 
name="store.menu" group="navigation-sections" 
template="Magento_Theme::html/container.phtml">
<arguments>
<argument name="title" translate="true" 
xsi:type="string">Menu</argument>
</arguments>
</block>
</referenceContainer>
 </body>

but nothing change

1 Answer 1

0

Strange that there is no full answer anywhere on this as it took me ages to work it out!

1 - Make sure you main pages (such as the home page) have a sidebar.

In admin: Content -> Pages and under the layout column change all to '2 columns with left bar'

2 - Make your child theme and activate it : https://meetanshi.com/blog/create-child-theme-in-magento-2/

3 - In your default.xml file put this:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <move element="catalog.topnav" destination="sidebar.main" before="-" />
    <move element="catalog.leftnav" destination="sidebar.main" after="catalog.topnav" />
</body>

The first move puts the top navigation in the side bar. The second move makes sure it appears before Layered Navigation on category pages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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