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!
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
In Yii2, a good way to accomplish this is by using the 'depends' option on registerCssFile as shown in the documentation
$this->registerCssFile("http://example.com/css/themes/black-and-white.css", [
'depends' => [BootstrapAsset::className()],
'media' => 'print',
], 'css-print-theme');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With