How do I add custom CSS or JS to for a particular page?
Suppose,i want add a custom css file for Checkout cart which will only show n at Cart.
Example: like a FAQ or any single page
3 Answers 3
if you want to add a css file to all cms pages add this to your local.xml
<layout>
<cms_page_view>
<reference name="head">
<action method="addItem">
<type>skin_css</type>
<name>path/to/file.css</name>
</action>
</reference>
</cms_page_view>
</layout>
If you want a css file just for the FAQ page, go to that CMS page and go to Design tab in the left menu and insert:
<reference name="head">
<action method="addItem">
<type>skin_css</type><name>path/to/file.css</name>
</action>
</reference>
You should add some CSS/JS files only in local.xml file in your magento theme.
app/design/frontend/PACKAGE/TEMPLATE/layout/local.xml
<layout>
<default>
<reference name="head">
<action method="addJs">
<script>path/to/file.js</script>
</action>
<action method="addItem">
<type>skin_css</type>
<name>path/to/file.css</name>
</action>
</reference>
</default>
</layout>
You can find the related phtml pages, here in your file directory
/app/design/frontend/default/YOURTHEME/template/page
depending on your theme, you might see files named
1column.phtml
2columns-left.phtml
2columns-right.phtml
3columns.phtml
You can find the header section in those files, where you can link your CSS files or js
-
Editing the .phtml files is not the correct way of adding a stylesheet.Agop– Agop2015年06月24日 00:31:27 +00:00Commented Jun 24, 2015 at 0:31