how to call navigation bar in magento 2.2.6
-
05-02-2021 - |
Question
How to call navigation main menu in magento2.2? please let me know.
I follow this code for our custom header in default.xml file.
<referenceContainer name="header.container">
<block class="Magento\Theme\Block\Html\Footer" name="myheader" template="html/myheader.phtml" before="-"/>
</referenceContainer>
<move element="minicart" destination="myheader"/>
<move element="top.search" destination="myheader"/>
<move element="logo" as="logo" destination="myheader"/>
Then echo this elements call in myheader.phtml file.
<?php echo $this->getChildHtml('minicart'); ?>
<?php echo $this->getChildHtml("logo"); ?>
<?php echo $this->getChildHtml("topSearch"); ?>
so my i have coming menu toggle but not display navigation bar please let me know how we can fix this issue.
Solution
as per screenshot https://prnt.sc/laljiy please put "Outfits", "shops" and "sale" category as child of "default category".
Let me know if it works.
OTHER TIPS
you need to add at default.xml
:
<?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>
<referenceContainer name="header.container">
<block class="Magento\Theme\Block\Html\Footer" name="myheader" template="html/myheader.phtml" before="-"/>
</referenceContainer>
<move element="minicart" destination="myheader"/>
<move element="top.search" destination="myheader"/>
<move element="logo" as="logo" destination="myheader"/>
<move element="catalog.topnav" as="nav" destination="myheader"/>
</body>
</page>
And in Phtml you can get at myheader.phtml
:
<?php echo $this->getChildHtml('minicart'); ?>
<?php echo $this->getChildHtml("logo"); ?>
<?php echo $this->getChildHtml("topSearch"); ?>
<?php echo $this->getChildHtml("nav"); ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange