I am struggling to add a non-category custom menu in the navigation bar and also a sub-menu. Please help. Thanks.
4 Answers
For people looking for a solution, I was facing the same issue, but after some research I found an event the Block which generate the menu. I also found another stack exchange response which worked for me.
one alternative solution is that
create one new category and assign cms block to it
and add cms page code to that cms block
everything works as per you needed.
You can try this way:-
Extend this file from core:-
app/design/frontend/<vendor_name>/<theme_name>/Magento_Theme/templates/html/topmenu.phtml
<nav class="navigation" data-action="navigation">
<ul data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}'>
<?php /* @escapeNotVerified */ echo $_menu; ?>
<?php /* @escapeNotVerified */ echo $block->getChildHtml(); ?>
<li>Test menu</li>
</ul>
</nav>
It will add a menu in the end.
-
this returns nothing. however, on switching to Luma theme, navigation is displayed Commented Jan 7, 2021 at 11:53
Please find the below code for Main menu and submenus.
<?xml version = "1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd">
<menu>
<!--Main Menu-->
<update id="Arise_Extensions::menu" title="Arise Extensions" module="Arise_Contact" sortOrder="10"
resource="Arise_Extensions::menu"/>
<!-- Sub Section 1 -->
<add id="Arise_Contact::contacts_manager" title="Arise Contacts" module="Arise_Contact" sortOrder="10"
parent="Arise_Extensions::menu" dependsOnModule="Arise_Contact"
resource="Arise_Contact::contacts_manager"/>
<!-- Sub Section 1 Links-->
<add id="Arise_Contact::manage_contacts" title="Manage Contacts" module="Arise_Contact" sortOrder="10"
parent="Arise_Contact::contacts_manager" action="Arise_contacts/manage_contacts"
resource="Arise_Contact::manage_contacts"/>
<add id="Arise_Contact::Arise_contacts_settings" title="Manage Contact Settings" module="Arise_Contact"
sortOrder="20" parent="Arise_Contact::contacts_manager"
action="adminhtml/system_config/edit/section/Arise_contacts"
resource="Arise_Contact::Arise_contacts_settings"/>
<!--/Sub Section 1 Links-->
</menu>
</config>
-
I want to add the menu item in the home page navigation bar in the frontend, not in the backend. :)– Mudz7Commented Feb 16, 2018 at 6:13