In Magento 2 if you are developing multiple modules under the same Namespace then should create a menu for all modules. So you can place all your modules setting or any URL under a single menu which will be your Namespace.

In this post, We will see how to add a custom module menu to the admin panel, how to add custom CSS to the admin panel, how to add system configuration and how to add menu icon in Magento 2.

 Magento 2 menu

First Let’s create module’s main files.

Start Module main files

Create Vky/Core/registration.php

Create Vky/Core/composer.json

Create Vky/Core/etc/module.xml

Required files for a simple module is now created.

End Module main files

Now let’s add the menu.

Start For menu

Create Vky/Core/etc/adminhtml/menu.xml

End For menu

That was for the menu Now let add system configuration.

Start For Store->Configuration->Our Module

Create Vky/Core/etc/adminhtml/system.xml

End For Store->Configuration->Our Module
Start For menu icon

Add an icon image file at Vky/Core/view/adminhtml/web/images/vky_logo.png

Now We will need CSS to add this image

Start to add CSS in the head admin panel

Create Vky/Core/view/adminhtml/web/css/vky.less

Create Vky/Core/view/adminhtml/layout/default.xml

End to add CSS in the head admin panel
End For menu icon

Now at the beginning of the post, I said you can place all your modules setting or any URL under a single menu which will be your Namespace.

We have Vky_Core module. And added in menu.
This module’s menu contains other menus like
– Vky
– General
– Extensions
– Services

And you will not able to sell all this menu because they don’t have any sub-menu. So if we create any module now we will add a menu for that under “Extensions”.

For example, you have created a new module Vky_Test. So all you need to do is open the menu.xml file of the Vky_Testmodule we will need to put below code.

Here parent=”Vky_Core::extensions” is responsible to add our menu uder “Extensions”.

If you want to download full source code Click here to download Vky_Core Module

Be kind to one another. Take care!

No Comments

Post A Comment