0

I was creating a custom menu in Magento 2 but this was not being shown!

file location: Magento2Root/app/code/Cloudways/Adminmenu/registration.php

other files:module.xml

third file: menu.xml enter image description here

screenshot of my code

| improve this question | | | | |
  • Post your code for menu.xml and provide path where you have created it. – anonymous Jun 22 '18 at 7:24
  • path menu.xml [ Magento2Root/app/code/Cloudways/Adminmenu/menu.xml ] and code show my screen shot – shohel hussain Jun 22 '18 at 12:43
1

Make sure that your module.xml is in the path - Magento2Root/app/code/Cloudways/Adminmenu/etc and menu.xml is in the path - Magento2Root/app/code/Cloudways/Adminmenu/etc/adminhtml

If this doesn't help then edit your question and add content of all the 3 files so that People can answer that.

| improve this answer | | | | |
1

Please verify that the path of menu.xml should be app/code/Cloudways/Adminmenu/etc/adminhtml/menu.xml.

Apart from that, if you are checking the menu item from a user with restricted permission role, then you must specify acl.xml in your module under app/code/Cloudways/Adminmenu/etc/acl.xml.

Edit: If you are having trouble in finding the cause of issue, then retry with the steps below:

Step 1: Create app/code/Stack/Adminmenu/registration.php and put the following content

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Stack_Adminmenu',
    __DIR__
);

Step 2: Create app/code/Stack/Adminmenu/etc/module.xml and put the following code

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Stack_Adminmenu" setup_version="0.1.0">
    </module>
</config>

Step 3: Create app/code/Stack/Adminmenu/etc/adminhtml/menu.xml and put the following code

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd">
    <menu>
        <add id="Stack_Adminmenu::first_level_demo"
             title="Admin Menu"
             module="Stack_Adminmenu"
             sortOrder="20"
             resource="Magento_Backend::content"
        />
        <add id="Stack_Adminmenu::second_level_demo"
             title="Sub Menu"
             module="Stack_Adminmenu"
             sortOrder="1"
             action="menuitem/index/index"
             parent="Stack_Adminmenu::first_level_demo"
             resource="Magento_Backend::content"
        />
    </menu>
</config>

Remember to define and create the controller class for the action where you are redirecting on clicking on the menu item.

| improve this answer | | | | |
1

You have to create ACL acl.xml

  • app/code/Cloudways/Adminmenu/etc/acl.xml

Also menu.xml should be under

  • app/code/Cloudways/Adminmenu/etc/adminhtml/menu.xml
| improve this answer | | | | |

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.