4

I've created a custom module and my adminhtml.xml is as follows...

<config>
<menu>
    <web translate="title" module="adminhtml">
        <title>Custom</title>
        <sort_order>110</sort_order>
        <children>
            <web>
                <title>User Info</title>
                <action>web/adminhtml_web</action>
            </web>
        </children>
    </web>
</menu>
<acl>
    <resources>
        <admin>
            <children>
                <Company_Web>
                    <title>Custom</title>
                    <sort_order>60</sort_order>
                    <children>
                        <web>
                            <title>User Info</title>
                            <action>web/adminhtml_web</action>
                        </web>
                    </children>
               </Company_Web>
           </children>
       </admin>
   </resources>
</acl>

The module works as expected if an admin account is logged in. I can see the module in the admin panel and in the Role Resource Tab (System->Permissions->Roles), but when I tried to check the module and save the user role, it will say that it has been saved. But when I rechecked the user role, it is still unchecked.

And when I tried to log in using the account with the said user role, the custom module is hidden. What seems to be the problem?

1
  • It could be a problem to use the same name "web" once for the parent AND once for the child. Try using different names for these. Also in the resources section you should not have an action tag.
    – mpaepper
    Feb 13, 2013 at 16:54

1 Answer 1

9

The problem here is that your resource has to match the menu name. This is a convention in Magento and if you do not do this, then it will show, but you cannot save the values. This is a problem I faced often before.

Here is a simple example of how it should work:

<?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>

EDIT: Also have a look here for a great tutorial of system configuration and ACL http://alanstorm.com/custom_magento_system_configuration

2
  • Nice.. thank you so much mpaepper.. You had saved me a lot of time on this one. Thanks for the tips and the tutorial. :) Feb 13, 2013 at 16:37
  • +1 for nice explain i have same problem and solve this thanks..
    – Keyur Shah
    Dec 26, 2013 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.