简体   繁体   中英

Magento 1.9 Enable Disable Module From Admin Panel

I have a task to create a Magento module that's override some phtml files, however, as the task requirement I need to control the module from system->configuration, by creating a tab for the module, then an option for enable disable the module .

How could I accomplish this, taken into consideration the module contains the phtml file to override.

Thank you,

Usually, I prefer to create block which will render those templates, then, you can use override _toHtml method and implement the logic there. Similar to what the Mage_Core_Block_Template does.

class Namespace_Module_Block_Template extends Mage_Core_Block_Template 
{
    ...

    protected function _toHtml()
    {
        if (!this->_isEnabled()) {
            return '';
        } 

        return parent::_toHtml();
    }

    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM