views:

46

answers:

2

What is the best way to determine if a particular module is enabled/active in Magento? I've tried using class_exists to check if my code has been loaded and parsed by PHP but lately I've noticed its pretty unreliable (returns true even when I delete the module's .xml configuration).

Is there a core function I can call?

A: 

There doesn't seem to be a core function specifically for that.

Look in the Mage_Core_Model_Config class. It appears to be what does most of the work in loading modules. Particularly _loadDeclaredModules() function (Version 1.4.0). You could override the class and create a function using what you see there.

Hope that helps

KThompson
+2  A: 

ok, something like this:

Mage::getConfig()->getNode()

which will return the global config as XML and then use XML parsing to search for the module declaration.

Cheers, JD

Jonathan Day
A module may not have a model.
Alan Storm
Yup, thanks Alan, realised that as soon as I hit submit :) Revised answer above.
Jonathan Day
Thanks! I was hoping for something like Mage::hasModule("Custom_Module") but I think your solution would work just fine :)
Colin O'Dell