Removing an Item from Magento's Admin Panel Navigation

23

Solution 1

Cleaner way to do this:

Add a adminhtml.xml (e.g. to an existing modules that keeps all other customization stuff, or create a new module)

<?xml version="1.0" ?>
<config>
    <menu>
        <xmlconnect>
            <disabled>1</disabled>
        </xmlconnect>
    </menu>
</config>

Solution 2

You could inject a bogus module dependency into the menu item in your config.xml.

In your case,

<adminhtml>
  <menu>
    <cms translate="title" module="cms">
      <depends><module>HideMe</module></depends>
    </cms>
  </menu>
</adminhtml>

Solution 3

I don't think Alan would still need anyone to ask this question, but for anyone else that might end up reading this, it would be a bit better to use:

<adminhtml>
  <menu>
    <cms translate="title" module="cms">
      <depends><config>some/configuration/flag</config></depends>
    </cms>
  </menu>
</adminhtml>

Solution 4

For a specific menu point you can use:

<?xml version="1.0"?>
<config>
    <menu>
        <customer>
            <children>
                <online>
                    <disabled>1</disabled>
                </online>
            </children>
        </customer>
    </menu>
</config>
Share:
23
Nicholas Oyagha
Author by

Nicholas Oyagha

Updated on June 05, 2022

Comments

  • Nicholas Oyagha
    Nicholas Oyagha almost 2 years
    import React from "react";
    import "./App.css";
    import Nav from "./Nav";
    import About from "./About";
    import Shop from "./Shop";
    import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
    
    function App() {
        return (
          <Router>
            <div className="App">
               <Nav />
                <Routes>
                  <Route path="/about" element={<About />} />
                  <Route path="/shop" element={<Shop />} />
                </Routes>
              </div>
             </Router>
           );
         }
    
    export default App;
    
  • Alan Storm
    Alan Storm about 15 years
    Your science impresses me! Will depends work like that in other areas of the config file? I'd only even seen it used to ensure correct module loading order.
  • Scott Moorhouse
    Scott Moorhouse about 15 years
    It seems to be only for initializing Magento's modules (as you stated) and building the adminhtml menu. Module dependencies seem to be checked in these classes: Mage_Adminhtml_Block_Page_Menu Mage_Adminhtml_Model_Config Mage_Adminhtml_Model_System_Config_Source_Admin_Page Mage_Api_Model_Config Mage_Core_Model_Config
  • Jonathan Day
    Jonathan Day about 13 years
    @Alan and @Scott just wondering if either of you found a more elegant way of doing this in the two years since posting. It seems a little ... hacky (no offense intended!). Thanks, JD
  • Alan Storm
    Alan Storm almost 12 years
    @JonathanDay It looks like modern version of Magento support a <disabled>1</disabled> node to turn a menu (or ACL rule) on/off.
  • Alan Storm
    Alan Storm over 11 years
    This is definitely the way to handle things in a modern version of Magento. I'm not sure if it's supported in older version, but if you're having trouble see the old, original accepted answer: stackoverflow.com/a/769931/4668