1

menu.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Ronis_Contactus::contactus" title="Contact us" translate="title" module="Ronis_Contactus" sortOrder="20" dependsOnModule="Ronis_Contactus" resource="Ronis_Contactus::contactus"/>
        <add id="Ronis_Contactus::ronis_contactus" title="Grid" translate="title" module="Ronis_Contactus" sortOrder="10" parent="Ronis_Contactus::contactus" action="contactus" resource="Ronis_Contactus::contactus"/>
    </menu>
</config>

acl.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Ronis_Contactus::contactus" title="Contact us" translate="title" sortOrder="30">
                </resource>
            </resource>
        </resources>
    </acl>
</config>
1
  • If some answer solved your problem, thanks to accept the answer to help other users
    – Aamir
    Mar 5 '19 at 15:16
1

Try this updated code :

etc/adminhtml/menu.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd">
    <menu>
        <add id="Ronis_Contactus::contactus" 
             title="Contact us" 
             translate="title"
             module="Ronis_Contactus" 
             sortOrder="20"
             resource="Magento_Backend::content"/>
        <add id="Ronis_Contactus::ronis_contactus" 
             title="Contact us Config" translate="title" 
             module="Ronis_Contactus" 
             sortOrder="10" 
             parent="Ronis_Contactus::contactus" 
             action="adminhtml/system_config/edit/section/contactus" 
             resource="Magento_Backend::content"/>
    </menu>
</config>

etc/acl.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::stores">
                    <resource id="Magento_Backend::stores_settings">
                        <resource id="Magento_Config::config">
                            <!-- this resource id we can use in system.xml for section -->
                            <resource id="Ronis_Contactus::config" title="Ronis Contactus" sortOrder="30" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>
0
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Vendor_ModuleName::first_level_demo"
             title="First Level Item"
             module="Vendor_ModuleName"
             sortOrder="9999"
             resource="Magento_Backend::content" />

        <add id="Vendor_ModuleName::second_level_demo"
             title="Second Level Item"
             module="Vendor_ModuleName"
             sortOrder="0"
             action="menuitem/index/index"
             parent="Vendor_ModuleName::first_level_demo"
             resource="Magento_Backend::content" />
    </menu>
</config>

Explanation of the directive’s attributes is as follows:

id – unique node identifier, should follow the format: Vendor_Module::menu_item_description

title – text that is shown in menu

module – current module

sortOrder – where to place menu item

resource – defines the ACL rule which the admin user must have in order to see and access this menu, it is defined in acl.xml. Otherwise, menu item won’t be rendered. For simplicity, Magento_Backend::content is used.

0

app/code/Vendor/Name/etc/adminhtml/menu.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Ronis_Contactus::contactus_head" title="Contact us" translate="title" module="Ronis_Contactus" sortOrder="20" dependsOnModule="Ronis_Contactus" resource="Ronis_Contactus::contactus_head"/>
        <add id="Ronis_Contactus::ronis_contactus" title="Grid" translate="title" module="Ronis_Contactus" sortOrder="10" parent="Ronis_Contactus::contactus_head" action="contactus" resource="Ronis_Contactus::contactus_child"/>
    </menu>
</config>

app/code/Vendor/Name/etc/acl.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Ronis_Contactus::contactus_head" title="Contact us" translate="title" sortOrder="30">
                    <resource id="Ronis_Contactus::contactus_child" title="Grid" sortOrder="10" />
                </resource>
            </resource>
        </resources>
    </acl>
</config>

And finally : php bin/magento c:f

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.