Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link Magento admin menu to role resources

Tags:

magento

Here's the situation:

I would like to add a Menu in the Magento backend navigation menu.
I accomplished this by adding the following code in app/etc/config.xml:

<adminhtml>
<menu>
    <example translate="title" module="adminhtml">
        <title>Inventory</title>
        <sort_order>110</sort_order>
        <children>
            <set_time>
                <title>Set It!</title>
                <action>helloworld/index/goodbye</action>
            </set_time>
        </children>
    </example>
</menu> 

The problem is I can't include this menu in the permission->role resources so I can't assign this to a specific user.

How do I include this menu in the permission->role resources?

Thank you and more power!

like image 707
Christian Young Avatar asked Aug 10 '10 09:08

Christian Young


2 Answers

You need to tell magento that you want your new menu position to be visible in the permission tree. To do this you have to add an ACL section to your configuration data. Put this inside your module's config.xml file:

     <acl>
        <resources>
            <admin>
                <children>
                    <example>
                            <title>Inventory</title>
                            <sort_order>110</sort_order>
                            <children>
                                <set_time>
                                    <title>Set It!</title>
                                    <sort_order>0</sort_order>
                                </set_time>
                            </children>
                    </example>
                </children>
            </admin>
        </resources>
    </acl>
like image 69
silvo Avatar answered Oct 02 '22 23:10

silvo


thanks.. I got it to work with a few tweakings..

<adminhtml>
    <acl>
        <resources>
            <admin>
                <children>

 <helloworld_options translate="label" module="helloworld">
  <title> MENU</title>
                    <sort_order>999</sort_order>
                    <children>
   <hello_children1>
    <title> RELATION</title>
                            <sort_order>10</sort_order>
   </hello_children1>
   <hello_children2>
    <title> MACHINE</title>
                            <sort_order>20</sort_order>
   </hello_children2>
   <hello_children3>
    <title> INVOICE</title>
                            <sort_order>30</sort_order>
   </hello_children3>
  </children>
 </helloworld_options>

                    <system>
                        <children>
                            <config>
                                <children>
                                    <helloworld_options translate="label" module="helloworld">
                                        <title> MENU</title>
                                    </helloworld_options>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</adminhtml>

this will display the following menu with sub menus in the backend.. plus this can be configured in the role resources.. :)

like image 23
Christian Young Avatar answered Oct 02 '22 22:10

Christian Young