Magento – Is It Possible To Move An Admin Menu Node

adminadminhtmlmenuxml

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.

Best Answer

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.

Related Topic