Yii register CSS file, to be the last one (after assets)

Philippe Boissonneault picture Philippe Boissonneault · Dec 10, 2012 · Viewed 18.5k times · Source

Is there a way in Yii to register js or css files to load them after those loaded by the assets manager.

I use a css file to override styles from some Yii extensions, but Yii includes my file before the assets generated by the extension.

I know I can change the extension to remove the css files from the assets manager and add them manually with registerCssFile but that's not the way I want to do this.

Here's what I have :

<head>
...
    <link rel="stylesheet" type="text/css" href="/css/MY_CSS.css" />
...
    <link rel="stylesheet" type="text/css" href="/assets/8e838803/css/EXTENSION_CSS.css" />
...
</head>

Here's what I want:

<head>
...
    <link rel="stylesheet" type="text/css" href="/assets/8e838803/css/EXTENSION_CSS.css" />
...
    <link rel="stylesheet" type="text/css" href="/css/MY_CSS.css" /> <!-- the last one -->
</head>

Any help would be appreciated!

Answer

Asgaroth picture Asgaroth · Dec 10, 2012

Registered assets by CClientScript are always added before the title

In your case you should add your CSS after the title, to guarantee the order you want