4

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.

  • do you want to add top menu, catalog.nav ? or you have custom menu ? – Naveed Asim Oct 26 '18 at 4:34
3

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.

  • 1
    do the need full. – Kruti Aparnathi Oct 26 '18 at 5:08
  • Good observation +1 – Pawan Oct 26 '18 at 5:20
0

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"); ?>
  • only nav not working "prntscr.com/lalh92" please check this screenshot – neha rani Oct 26 '18 at 4:31
  • I think you you missed some tag in xml Or you need to flush cache.I have put whole code, please try again. – Pawan Oct 26 '18 at 4:35
  • Remember to flush cache.Above code is tested. – Pawan Oct 26 '18 at 4:38
  • prntscr.com/lali6e – neha rani Oct 26 '18 at 4:39
  • Please check my this screenshot please let me know."prntscr.com/lali6e" – neha rani Oct 26 '18 at 4: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.