0

I am trying to add a custom js file into my catalog product view page but the same is not happening.

I placed my js file inside skin\frontend\default\ucs_personalization\js\personalization.js

And below is the snippet of layout catalog.xml

<catalog_product_view translate="label">
.
.
.
<reference name="head">
<action method="addJs"><script>ucs_personalization/js/personalization.js</script></action>
</reference>
.
.
.
</catalog_product_view>

On the page view source i can see it takes the js from root\js. Below is page source script. It says that magento looks the js file inside root js directory

<script type="text/javascript" src="http://192.168.100.68/magento/js/ucs_personalization/js/personalization.js"></script>

3 Answers 3

2

You can make it use the skin folder like this:

<action method="addItem"><type>skin_js</type><name>js/yourfile.js</name></action>
2

When you use this structure:

<reference name="head">
    <action method="addJs"><script>ucs_personalization/js/personalization.js</script></action>
</reference>

you should have your personalization.js in following tree format:

js/ucs_personalization/js/personalization.js

**If you want to keep your js inside skin folder then use this:

<action method="addItem">
  <type>skin_js</type>
  <name>js/personalization.js</name>
</action>
1
<catalog_category_view>
    <reference name="head">
        <action method="addItem">
            <type>skin_js</type>
            <name>js/personalization.js</name>
        </action>
    </reference>
</catalog_category_view>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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