0

I developing magento module which creates menu in admin panel. But when I disable it I would like not to show it. I saw this question : Possible to hide admin menu if custom module is disabled? I added the code to my module file (to see if this method is working) in my adminhtml.xml

<config>
    <menu>
    <depends>
         <config>payment/checkmo/active</config>
        </depends>

and then went to System->Configuration->Payment methods and disabled payment method Check/money order ?

What did I do wrong? What config path should be to check if my module is enabled ?

Thanks in advance.

1

Your code appears to be one level too far up in the xml it should look as follows:

<config>
    <menu>
        <menu-type> <!-- e.g. <catalog> -->
            <depends>
                <config>payment/checkmo/active</config>
            </depends>
        </menu-type>
    </menu>
<config>

Note the missing menu-type node from your original code snippet.

If you look into the database table core_config_data for the path you will see that the entry is set to 1 when the module is disabled from the advanced tab. This means that the code that normally works for the menu will sadly not work for disabling modules via the admin config section and will in fact disable the menu item when the module is active.

The best suggestion would be to do the disable on the main module active flag and then change the module to active/inactive via the xml file under app/etc/modules. The following will remove the menu item when Example_Module is disabled.

<depends>
    <module>Example_Module</module>
</depends>
  • Ok, so this is working with payment/checkmo example. But as I mentioned in my question I would like to show the menu item only when module is enabled in System->Configuration->Advanced. I tried this code snippet but it shows menu only when module is DISABLED and hides when enabled (should be reverse):<config> <menu> <catalog> <depends> <config>advanced/modules_disable_output/Company_ModuleName</config> </depends> I tried to change modules_disable_output to modules_enable_output but it's not working – intentarr May 17 '14 at 7:03
  • @intentarr sew update – David Manners May 17 '14 at 7:38
  • Ok, now it's clear, thanks for your answer :) – intentarr May 17 '14 at 7:43
1

How are you disabling the module? If you're disabling it through the System > Configuration > Advanced > Advanced, it won't fully disable the module.

Try setting the 'active' in the /app/etc/modules/Namespace_Modulename.xml file to 'false'.

1

If you disabled module from the admin panel (System > Configuration > ), the module won't be completely disabled. Instead of that what will happen is, it'll only disabled the out put of the module. Means the module source will still be executed.

So, the best way to disable a module completely is to open the module activation file in app/etc/modules/Namespace_Module.xml and set the <active> node value to false.

e.g.
<active>false</active>

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.