Magento1: How to set a dependency in a system XML of new extension
As far as I understand what you need, you should use <depends
tag, example from app/code/core/Mage/Paypal/etc/system.xml
:
<payment_action translate="label">
<label>Payment Action</label>
<config_path>payment/paypal_express/payment_action</config_path>
<frontend_type>select</frontend_type>
<source_model>paypal/system_config_source_paymentActions_express</source_model>
<sort_order>30</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<shared>1</shared>
</payment_action>
<authorization_honor_period translate="label comment">
<label>Authorization Honor Period (days)</label>
<comment>Specifies what the Authorization Honor Period is on the merchant’s PayPal account. It must mirror the setting in PayPal.</comment>
<config_path>payment/paypal_express/authorization_honor_period</config_path>
<frontend_type>text</frontend_type>
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<shared>1</shared>
<depends><payment_action>Order</payment_action></depends> <!-- see this line -->
</authorization_honor_period>
Dependencies can be set in your app/etc/modules XML. Magento will check if the extension is available.
<?xml version="1.0"?>
<config>
<modules>
<Your_Extension>
<active>true</active>
<codePool>community</codePool>
<depends>
<3thparty_Extension/>
</depends>
</Your_Extension>
</modules>
</config>
Or use the following code to check if an extension is enabled. This can be done by creating a helper method in Namespace/Module/Helper/Data.php
class Namespace_Module_Helper_Data extends Mage_Core_Helper_Abstract
{
public function extensionEnabled()
{
return Mage::getStoreConfig('advanced/modules_disable_output/Namespace_Module');
}
}