I have three fields in admin config section that have to be checked. If at least one of them is set to true the files should load.


<reference name="head">
    <action method="addItem">
    <action method="addItem">


  1. add a helper for each file
  2. add a new (hidden?) field to config and at sections save_before set value depending of the other fields
  3. Extended ifconfig extension is already is installed, but no idea how to set up condtions

At the moment I prefer 2nd one ...

Any other ideas? Any suggestions?

  • Use ifconfig like this tag <action method="addItem" ifconfig="my_config_section/advanced/load_js"> <type> skin_js </type> <name>js/my_module/my_module.js</name> </action> – Sumil sanghavi Jun 30 '17 at 14:29

Solved it this way for now:


<action method="addItem" ifconfig="[section]/[group]/enabled">




public function setModuleEnabledDisabled(Varien_Event_Observer $observer)
    if (!$website = $observer->getWebsite()) {
        $scope = 'default';
        $scopeId = 0;
    } elseif (!$store = $observer->getStore()) {
        $scope = 'websites';
        $scopeId = Mage::app()->getWebsite($website)->getId();
    } else {
        $scope = 'stores';
        $scopeId = Mage::app()->getStore($store)->getId();

    if ($scope == 'websites') {
        $storeId = Mage::app()->getWebsite($website)->getDefaultStore()->getId();
    } else {
        $storeId = $scopeId;

    $path = '[module]/[section]/';
    $value = Mage::getStoreConfigFlag($path . 'to_cart', $storeId)
          || Mage::getStoreConfigFlag($path . 'to_compare', $storeId)
          || Mage::getStoreConfigFlag($path . 'to_wishlist', $storeId);

    try {
        Mage::getConfig()->saveConfig($path . 'enabled', (int) $value, $scope, $scopeId);
    } catch (Exception $e) {

If you have any better Ideas ...


Please follow this link it will help you http://magebase.com/magento-tutorials/quick-tip-conditional-loading-of-javascript-and-css-using-your-module-configuration/

  • Thanks, but I have to check multible conditions. – sv3n Jun 30 '17 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.