The question:
I am working on a custom backend module that has an option in System > Configuration to enable or disable the module.
I would like to know if it is possible to hide the navigation item from the admin dashboard if the module is disabled?
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
There’s a good article by Ecomdev that gives an example of how you can do this with the ‘depends’ functionality. Search for ‘depends’ on that page and it will demonstrate how to use a config value. e.g.
<depends>
<config>payment/checkmo/active</config>
</depends>
The menu item will only show if the check payment method is active.
http://www.ecomdev.org/2010/10/28/defining-acl-resources-custom-and-admin-menu-in-magento.html
Method 2
The adminhtml.xml
and the config.xml
are both loaded into the configuration xml (Mage::getSingleton('admin/config')->getAdminhtmlConfig()
), so yes sure it is possible.
app/code/core/Mage/Admin/Model/Config.php:59
Mage::getConfig()->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
I think you have two options, either disable the menu in ACL.
Mage::getConfig()->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
or unset the node directly in the config. See Mage_Adminhtml_Block_Page_Menu::_buildMenuArray
But I think both is not possible at the moment with the API Mage_Admin_Model_Config
offers, so you maybe need to rewrite Mage_Admin_Model_Config
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0