magento-1.9 css phtml – How to Load CSS in .phtml File in Magento 1.9

cssmagento-1.9phtml

i have a custom css for specific page which is category product page, i want to include this css only when i load this page, as i know the page is located in theme/default/template/catalog/category/page.phtml, is there any way to do this ?

basically i have to include it like this in my phtml:

<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl('style/reset.css'); ?>" />

Best Answer

For display css on category page. please follow as below

put your css file in your theme

ex . skin/frontend/YourPackage/YourTheme/css/yourcssname.css

in your theme's local.xml located in app/design/frontend/YourPackage/YourTheme/layout/local.xml

Put below code in layout node.

<catalog_category_default>
    <reference name="head">
        <action method="addItem"><type>skin_css</type><name>yourcssname.css</name></action>
    </reference> 
</catalog_category_default>
<catalog_category_layered>
    <reference name="head">
        <action method="addItem"><type>skin_css</type><name>yourcssname.css</name></action>
    </reference> 
</catalog_category_layered>
Related Topic