3

I am using the cjm colorselectorplus module.

In their xml they have this line:

<action method="addJs"><script helper="colorselectorplus/data/canShowjQuery" /></action>

and in Data.php

class CJM_ColorSelectorPlus_Helper_Data extends Mage_Core_Helper_Abstract
{   
public function canShowjQuery()
    {
        if(Mage::getStoreConfig('color_selector_plus/zoom/enabled') == true && Mage::getStoreConfig('color_selector_plus/zoom/zoomexists') == false) {
            return 'cjm/colorselectorplus/jquery-1.6.4.min.js';
        }
    }

what this does is loading js/cjm/colorselectorplus/jquery-1.6.4.min.js into the website if color_selector_plus/zoom/enabled == true. I want to remove that file with my local.xml and I do this

    <default>
        <reference name="head">
            <action method="removeItem"><type>js</type><name>cjm/colorselectorplus/jquery-1.6.4.min.js</name></action>
       </reference>
    </default>

with no avail.

As I understand it, that js file is loaded through xml and should be removable through local.xml.

If I comment out <action method="addJs"><script helper="colorselectorplus/data/canShowjQuery" /></action> the file is being excluded. So I don't understand what's wrong.

2

It looks like the js file you are trying to remove is added to the root js folder (not the skin js folder) if so this should be the local.xml code you need.

<?xml version="1.0"?>
<layout>
    <default>
        <reference name="head">
            <!--Remove JS, js Folder-->
            <action method="removeItem">
              <type>js</type>
              <name>cjm/colorselectorplus/jquery-1.6.4.min.js</name>
            </action>
        </reference>
    </default>
</layout>

If instead the file is located in your skin directory (meaning it is part of the theme) it would look like this:

<?xml version="1.0"?>
<layout>
    <default>
        <reference name="head">
            <!--Remove CSS and JS, skin Folder-->
            <action method="removeItem">
              <type>skin_js</type>
              <name>cjm/colorselectorplus/jquery-1.6.4.min.js</name></action>
        </reference>
    </default>
</layout>

Both of those are also assuming that : <action method="addJs"><script helper="colorselectorplus/data/canShowjQuery" /></action> is being added to : <reference name="head"> Double check that file and see if it is being added to a different block and if so change the reference name="" accordingly.

Once your changes are saved go to the admin System - Cache Management and be sure to flush all Magento caches (Flush Magento Cache button, Flush Cache Storage Button, Select All - Refresh - Submit, Flush Javascript/CSS Cache).

2

The problem was the handle. It seems that a page handle like <catalog_product_view> has a higher precedence over the <default> handle.

The js file was included as

<catalog_product_view>
    <reference name="head">
        <action method="addJs"><script helper="colorselectorplus/data/canShowjQuery" /></action>
   </reference>
</catalog_product_view>

Doing this in local.xml will not remove it:

<default>
    <reference name="head">
        <action method="removeItem"><type>js</type><name>cjm/colorselectorplus/jquery-1.6.4.min.js</name></action>
   </reference>
</default>

But this will:

<catalog_product_view>//same handle as in the xml file that inserted it
    <reference name="head">
        <action method="removeItem"><type>js</type><name>cjm/colorselectorplus/jquery-1.6.4.min.js</name></action>
   </reference>
</catalog_product_view>

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.