skip to Main Content

I already know how to disable module output in the system config by going to System>Configuration>Advanced and by setting <active>false</active> in etc/modules. What I want to know is how to disable module using the custom tab that I created using system.xml.

3

Answers


  1. You can add that New Enable/Disable field in system.xml , and before your module any code execute check this field value if that is enable then execute otherwise not,this way it can be possible.

    Login or Signup to reply.
  2. you have to use ifconfig in your xml file

    for example you make a field in your system.xml

     <enable translate="label">
    <label>enable</label>
    <frontend_type>select</frontend_type>
    <source_model>adminhtml/system_config_source_yesno</source_model>
    <sort_order>10</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    

    And in your xml file

    <block class="your Blockname" name="name of field" ifconfig="sectionname/groupname/enable">
    

    using if config if your module is enable then it will display otherwise it will not display..!

    Login or Signup to reply.
  3. Add this code to your system.xml

    <fields>
        <enable translate="label">
            <label>Enable</label>
            <frontend_type>select</frontend_type>
            <source_model>adminhtml/system_config_source_yesno</source_model>
            <sort_order>0</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <comment>enable/disable the module</comment>
        </enable>
    </fields>
    

    And check this in your code: before your first Action in the module.(this might be in your cron.php or observer.php or indexcontroller)

    $isenabled = Mage::getStoreConfig('section_name/group_name/enable');
    if (!$isenabled) {
        return;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search