2

I have installed YII2 of my local server and I want to include separate css file from specific view or controller action, I have used a method but the method on include one css file in my specific view , could any one answer me for the solution my code is below. The firs file is include and the remaining is ignored.

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/iCheck/flat/blue.css", [
    'depends' => [BootstrapAsset::className()],
    'media' => 'screen',
], 'css-screen-theme');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/morris/morris.css", [
    'depends' => [BootstrapAsset::className()],
    'media' => 'screen',
], 'css-screen-theme');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/jvectormap/jquery-jvectormap-1.2.2.css", [
    'depends' => [BootstrapAsset::className()],
    'media' => 'screen',
], 'css-screen-theme');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/datepicker/datepicker3.css", [
    'depends' => [BootstrapAsset::className()],
    'media' => 'screen',
], 'css-screen-theme');

1 Answer 1

2

Just remove one parameter from the above code , the remaining code is correct.I am sending an example for modified code.

this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/iCheck/flat/blue.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], '');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/morris/morris.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], '');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/jvectormap/jquery-jvectormap-1.2.2.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], '');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/datepicker/datepicker3.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], ''); Now all the css files will be shown now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.