views:

53

answers:

2

The Magento backend allows you to disable module output per site. I've done some Google searches but can't figure out how to grab this value through my code. Basically when my module's output is disabled that works just fine. But I've discovered (the hard way) that Magento doesn't prevent the module from loading per-site.

Because I'm extending some core classes, some constructors are still being executed. My thought is to check if the module output is disabled. If so, have my constructor call the parent's constructor. If the module output is enabled, proceed with my custom code.

I just can't figure out how to grab this value for the current site (I am multi-sited, BTW). Ideally it would be something like this:

$isThisEnabled = Mage::app()->getCurrentStore()->isOutputEnabled('myModule');

Basically have a single line that fetches the current site's value (or the default, if not specified for the current site).

Any help would be greatly appreciated!

EDIT: I found the table core_config_data, which appears to store this information. I could manually query it if I had to, but I feel like Magento would have something built-in to return the current store's value, falling back to the default value.

+2  A: 

It is a standard config setting, so accessing it should be no different than accessing any other config setting. You just need to know what is the path to this value. Analysing the DB I believe this should do the trick:

Mage::getStoreConfig('advanced/modules_disable_output/Namespace_Module');
silvo
Thanks, that's exactly what I needed.
Colin O'Dell
A: 

The other option is that the Mage_Core_Helper_Abstract has an isModuleEnabled($moduleName = null) method, which means that you should be able to call:

Mage::helper('core/data')->isModuleEnabled('Namespace_Module')

There is also a isModuleOutputEnabled() method. Looking at the code, these don't seem to be filtered by store/view, whereas @silvo's method is.

Cheers, JD

Jonathan Day