Viktor Hesselbom

Viktor Hesselbom

« Go back home

Magento: Including external stylesheet

Ever tried including an external stylesheet in Magento? If you put the following in your theme's page.xml Magento won't recognize that it's in fact an external stylesheet we're trying to include and not a local one:

<action method="addCss"><stylesheet>http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css</stylesheet></action>

So instead we have to inject text with the link-tag directly like so:

<block type="core/text" name="google.cdn.jquery.ui.css">
    <action method="setText">
        <text><![CDATA[<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css" type="text/css" rel="stylesheet" />]]></text>
    </action>
 </block>

This isn't immediately apparent so maybe my research will help someone.