I have a small piece of code in a template file that I ONLY want to run if a certain module is installed. I found the below code, which you can use to find if a module is active, but I want to know if a module is installed.
$modules = Mage::getConfig()->getNode('modules')->children();
$modulesArray = (array)$modules;
if($modulesArray['Mage_Paypal']->is('active')) {
echo "Paypal module is active.";
} else {
echo "Paypal module is not active.";
}
I'm thinking I could maybe get a list of names of all the modules that are installed, and then use
if (stristr($modulelist, 'Name_Extension'))
to show my code only if the referenced extension is installed.
Anyone any ideas how to do that? Or any better solutions?
check them out under System > Configuration > Advanced > Advanced. And you can find out what's installed from app/etc/modules/. Magento "extensions" add code to the configuration based MVC system.
1. Check Magento version via Admin Panel. In order to check the Magento version, you need to log into your Magento Admin Panel. Once you scroll down the page, you will see the Magento version in the bottom (footer) right corner.
There's a core helper for that:
Mage::helper('core')->isModuleEnabled('MyCompany_MyModule');
It's in Mage_Core_Helper_Abstract
.
There's also a isModuleOutputEnabled()
method to check if output of module is disabled in System -> Configuration -> Advanced -> Disable Modules Output.
Try this:
$modules = Mage::getConfig()->getNode('modules')->children();
$modulesArray = (array)$modules;
if(isset($modulesArray['Mage_Paypal'])) {
echo "Paypal module exists.";
} else {
echo "Paypal module doesn't exist.";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With