4

We're using Fishpig's Attribute Splash module which inserts a node "Splash" at the top level of the admin menu. We'd prefer it to live under the Catalog menu though. Here's the original XML the module uses to insert the menu node (in adminhtml.xml):

 <menu>
    <attributeSplash translate="title" module="attributeSplash">
        <title>Splash</title>
        <sort_order>31</sort_order>
        <children>
            <pages translate="title">
                <title>Manage Pages</title>
                <action>attributeSplash_admin/adminhtml_page</action>
                <sort_order>11</sort_order>
            </pages>
            <groups translate="title">
                <title>Manage Groups</title>
                <action>attributeSplash_admin/adminhtml_group</action>
                <sort_order>6</sort_order>
            </groups>
        </children>
    </attributeSplash>
</menu>

I've created a separate module with the following in it's adminhtml.xml. This disables the original menu node and creates a new one with the same children under the catalog menu:

<menu>
    <!-- Disable default menu node -->
    <attributeSplash>
        <disabled>1</disabled>
    </attributeSplash>
    <!-- Create replacement -->
    <catalog>
        <children>
            <attribute_splash translate="title" module="attributeSplash">
                <title>Attribute Splash (Brands)</title>
                <sort_order>100</sort_order>
                <children>
                    <pages translate="title">
                        <title>Manage Pages</title>
                        <action>attributeSplash_admin/adminhtml_page</action>
                    </pages>
                    <groups translate="title">
                        <title>Manage Groups</title>
                        <action>attributeSplash_admin/adminhtml_group</action>
                    </groups>
                </children>
            </attribute_splash>
        </children>
    </catalog>
</menu>
<!-- Access control nodes so non-administrators can be given access -->
<acl>
    <resources>
        <admin>
            <children>
                <catalog>
                    <children>
                        <attribute_splash translate="title" module="attributeSplash">
                            <title>Attribute Splash (Brands)</title>
                            <sort_order>100</sort_order>
                            <children>
                                <pages translate="title">
                                    <title>Manage Pages</title>
                                </pages>
                                <groups translate="title">
                                    <title>Manage Groups</title>
                                </groups>
                            </children>
                        </attribute_splash>
                    </children>
                </catalog>
            </children>
        </admin>
    </resources>
</acl>

This will work fine for now, but if the Fishpig Attribute Splash module is updated with different menu nodes I'll need to make sure to change this xml to match. What I'm wondering if if anyone knows of a cleaner solution. Is there a way to simply move a menu node rather than disabling it and creating a new one? I wouldn't be too surprised if there isn't, but if there is I'd like to know about it since it would be slightly more upgrade proof.

1
  • 1
    Sounds like this is the best solution available. Thanks for the tip on the isAllowed method, @SanderMangel. In this particular case it wasn't being used, but good to know for the future. I did need to add new ACL nodes though before a non-admin user could see the menu items. Also it turns out ACL nodes can't use capital letters as mentioned in this StackOverflow post. For a while I was quite confused about why the checkboxes wouldn't save. – Zeke Farwell Sep 16 '13 at 18:52
4

As far as I know this is the cleanest and best solution to do so. I've tried it in different ways but it all requires 'hardcoded' values at some level.

Just a small tip, when you change the placement of the menu item you should check for the _isAllowed method in the adminhtml controller. There's probably a line of code like

return Mage::getSingleton('admin/session')->isAllowed('admin/attributesplash');

that will have to be changed to

 return Mage::getSingleton('admin/session')->isAllowed('admin/catalog/attributesplash');

to allow users who are not super admins to access it.

1
  • I was about to write something similar. So +1. – Marius Sep 16 '13 at 15:39
0

No, I don't believe there's a way to move the menu node in a way other than disabling and recreating it. I've used this technique myself a handful of times.

Edit: Actually, one way that you could do a move would be to overload Mage_Adminhtml_Block_Page_Menu::getMenuArray() and modify the contents of the menu array after it's constructed from the underlying XML.

I don't think this is a very clean solution, but it is an option. If you did that, you would have to manually modify the level parameter for the menu node as well as it's children once you moved it.

0

To complete @Sander Mangel answer you should also check the _setActiveMenu in the controller and also some block files. Some times you can display or hide some buttons (save / edit / delete) depending on the permissions. So check in /Blocks/Adminhtml/ Grid, Edit, Form, Tabs, ...

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.