문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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"); ?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top