0

The custom module menu shows under Role Resources. Under Role Resources I click the check-box and save. I then reload the role and the check-box is no longer checked. I basically copied the menu items to the ACL XML element. Why is this happening?

config.xml

<?xml version="1.0"?>
<config>
...
    <adminhtml>
        <menu>
            <customModuleHeader translate="title" module="custommodule">
                <title>customModule</title>
                <sort_order>60</sort_order>
                <children>
                    <custommodule_configform translate="title" module="custommodule">
                        <title>custommodule Configuration</title>
                        <sort_order>50</sort_order>
                        <children>
                            <custommodule_configform translate="title" module="custommodule">
                                <title>Settings</title>
                                <action>custommodule/adminhtml_configuration</action>
                                <sort_order>10</sort_order>
                            </custommodule_configform>
                        </children>
                    </custommodule_configform>
                </children>
            </customModuleHeader>
        </menu>
        <layout>
...

admin.html

<?xml version="1.0"?>
<config>
    <acl>
        <resources>
            <admin>
                <children>
                    <customModuleHeader translate="title" module="custommodule">
                        <title>customModule</title>
                        <sort_order>60</sort_order>
                        <children>
                            <custommodule_configform translate="title" module="custommodule">
                                <title>custommodule Configuration</title>
                                <sort_order>50</sort_order>
                                <children>
                                    <custommodule_configform translate="title" module="custommodule">
                                        <title>Settings</title>
                                        <sort_order>10</sort_order>
                                    </custommodule_configform>
                                </children>
                            </custommodule_configform>
                        </children>
                    </customModuleHeader>
                </children>
            </admin>
        </resources>
    </acl>
</config>
4

This is syntax how to create the Menu in Magento Admin Panel you can follow this

/app/code/local///etc/adminhtml.xml

<?xml version="1.0"?>
<config>
<menu>
    <[module] module="[module]">
        <title>[Module]</title>
        <sort_order>71</sort_order>               
        <children>
            <items module="[module]">
                <title>Manage Items</title>
                <sort_order>0</sort_order>
                <action>[module]/adminhtml_[module]</action>
            </items>
        </children>
    </[module]>
</menu>
<acl>
    <resources>
        <all>
            <title>Allow Everything</title>
        </all>
        <admin>
            <children>
                <[module]>
                    <title>[Module] Module</title>
                    <sort_order>200</sort_order>
                </[module]>
            </children>
        </admin>
    </resources>   
</acl>
<layout>
    <updates>
        <[module]>
            <file>[module].xml</file>
        </[module]>
    </updates>
</layout>

1

This happens because of menu section tags are not similar to ACL tags. I checked the code snippets provided by you. But there were no any mistakes. I suggest you to check these both sections (menu declaration and ACL) thoroughly.

(At the same time make sure you have NOT defined ACL inside admin.html as per in your question )

You can put both menu declaration and ACL inside adminhtml.xml

Below is a sample code which you can follow.

<?xml version="1.0" ?>
<config>
    <menu>
        <mycustom_menu translate="title" module="YOUR_MODULE_NAME">
            <title>My Menu</title>
            <sort_order>100</sort_order>
            <children>
                <!-- children -->
                <subitem translate="title" module="YOUR_MODULE_NAME">
                    <title>Subitem</title>
                    <sort_order>10</sort_order>
                    <action>adminhtml/mycustom_controller/</action>
                </subitem>
            </children>
        </mycustom_menu>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <mycustom_menu translate="title" module="YOUR_MODULE_NAME">
                        <title>My Menu</title>
                        <sort_order>300</sort_order>
                        <children>
                            <!-- children -->
                            <subitem translate="title" module="YOUR_MODULE_NAME">
                                <title>Subitem</title>
                                <sort_order>10</sort_order>
                            </subitem>
                        </children>
                    </mycustom_menu>
                </children>
            </admin>
        </resources>
    </acl>
</config>
  • +1 It got me a little bit further. Because my menu is shown and the resource is available in the ACL list. But when I grant acces for a user throug a role, the menu gets visible but when I click it it says access denied. Any ideas how I can solve that? – Akif Apr 5 '16 at 11:24

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.