0

I am new in magento 2. i am facing a problem with default top-menu block. I create a custom header and i want to move top-menu block in my custom header. But not get success Code:

Custom header file :

<div class="header">  <?php //echo $this->getChildHtml("logo"); ?> 
        <div class="container">
             <div class="nav-top">
                <?php echo $this->getChildHtml("catalogTopnav"); ?> 
             </div>
</div>
</div>

layout/default.xml

<referenceContainer name="header.container">
             <block class="Magento\Framework\View\Element\Template" 
              name="custom_header" as="custom_header" 
              template="Magento_Theme::html/customheader.phtml"  before="-" /></referenceContainer>    
<move element="catalog.topnav" destination="custom_header" after="logo" />

Please help me any one how to print top menu item in my custom header. thanks in advance

0

you are moving the catalog.topnav element in your layout file, but are asking for the catalogTopnav element in your template file. The easiest solution is to change the code as followed.

<?php echo $this->getChildHtml("catalog.topnav"); ?> in your template file

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.