0

I'm trying to add a custom CSS file when a Magento action is loaded.

My layout page is as follows :

<layout version="0.1.0">

<helloworld_index_index>
  <reference name="head">

        <action method="addCss">
            <stylesheet>css/custom.css</stylesheet>
        </action>
    </reference>
       <reference name="root">
         <block type="page/html" name="root"  output ="toHtml" template = "mypage.phtml"/>

     </reference>

</helloworld_index_index>
</layout>

The content of mypage.phtml displays without a problem but the CSS is not loaded. The path to my css is :

skin\frontend\base\default\css\custom.css

0

The path to the stylesheet directory will depend on what you have set in System=>Configuration=>General=>Design=>Themes=>Skin (Images / CSS) so depending on what you have set there, it will look in that directory for the CSS file.

You can easily find out where Magento is looking for that stylesheet by going on the frontend of the website and looking at the console log, there should be a 404 for the custom.css file.

Always make sure to flush your cache when you make layout changes

  • The skin config is empty ,i'm using default magento install with sample data. And i see not 404 error for the css file in the console. – mockingbid Nov 21 '18 at 17:29
  • did you flush/clear the cache? – Haim Nov 21 '18 at 17:30
  • Use i deleted the var cache folder and i have already disabled all cache – mockingbid Nov 21 '18 at 17:32
  • did you try <action method="addItem"><type>skin_css</type><name>css/custom.css</name></action> – Haim Nov 21 '18 at 17:39
  • It didn't work. Same result :/ – mockingbid Nov 21 '18 at 17:48
0

you can try below code this code work for me

<reference name="head">
    <action method="addItem">
        <type>skin_css</type>
        <name>css/custom.css</name>
    </action>
</reference>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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