How Can I move a search bar in Navigation div in Magento 2 via XML?
You can put a search box after the navigation block and use css to make display it in one line, since html/topmenu.phtml block doesn’t print its child’s
1 |
<move element="top.search" destination="page.top" after="catalog.topnav" /> |
Alternatively, you can overwrite html/topmenu.phtml to
1 |
<?php $columnsLimit = $block->getColumnsLimit() ?: 0; ?> <?php $_menu = $block->getHtml('level-top', 'submenu', $columnsLimit) ?> <nav role="navigation"> <ul data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}'> <?php echo $_menu; ?> </ul> <?php echo $block->getChildHtml() ?> </nav> |
More tips from Magento 2 Developer’s Cookbook
Source (