Adding Custom CSS/JavaScript to Certain CMS Pages with Custom JS Path in Magento

cmslayoutmagento-1.9static-block

I tried the both ways,

Method 1:

<reference name="head">
   <action method="addItem">
       <type>skin_js</type><name>js/myJs.js</name>
   </action>
</reference>

The above gives default skin directory.

Method 2:

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

The above gives js directory.

But I Need the file located like the below to add via block and reference head.

src Path: http://www.example.com/wp/folder1/folder2/script.js

Here the http://www.example.com is store url.

How to implement this?

Best Answer

Try bellow way

Add custom CSS or JavaScript to CMS Pages With Custom JS Path

<reference name="head">
  <action method="addItem"><type>skin_js</type><name>js/your_foldername/your_js_name.js</name></action> 
  <action method="addItem"><type>skin_css</type><name>css/your_foldername/your_css_name.css</name><params/></action>
</reference>

Go admin side and add above code in CMS page in section (Layout Update XML) enter image description here