Add css to only homepage from xml in magento
Solution 1
In the cms home page there is Design(Layout Update XML) use the following code in that
<reference name="head">
<action method="addItem"><type>skin_js</type><name>js/myjavascript.js</name></action>
</reference>
Solution 2
this solution work for me
<cms_index_index translate="label">
<label>CMS Home Page</label>
<reference name="head">
<action method="addCss">
<stylesheet>
css/custom.css /*This is ur css path*/
</stylesheet>
</action>
</reference>
</cms_index_index>
Solution 3
Try this
<cms_index_index>
<reference name="your cms identifier for home page">
<action method="addCss"><stylesheet>your path/your css file name</stylesheet></action>
</reference>
</cms_index_index>
Please use this code in local.xml
or page.xml
Am not 100% sure about the code work or not
Solution 4
In combination with @Leo's answer as well as another blog post I found recently, here's a code snippet to add custom css to just a single page only.
<reference name="head">
<action method="addCss">
<stylesheet>css/custom.css</stylesheet>
</action>
</reference>
Same instructions as @Leo mentioned.
Solution 5
The above suggestions didn't work for me in Magento 1.7, blank theme. What worked was this:
<reference name="head">
<action method="addCSS">
<type>css/master.css</type>
<stylesheet>media="all"</stylesheet>
</action>
</reference>
This produced the following code
<head><link rel="stylesheet" type="text/css" href="http://myshop.com/shop/skin/frontend/mytheme/blank/css/master.css" media="all"></head>
I placed this code into the local.xml of my theme.
Comments
-
Nikhil_K_R almost 2 years
Want to include css file which is applicable to only homepage from xml file.
Tried this :<cms_index_index> <action add css> . . </action> </cms_index_index>
using this in local.xml adds that particular css in every cms page.
Any Idea ?
Thanks in Advance.