PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 8, 2022

[FIXED] Yii2: Preventing a specific CSS file from getting loaded

 February 08, 2022     php, yii, yii2, yii2-basic-app     No comments   

Issue

I need to stop loading the bootstrap.css file in one view to void duplicate. But I don't know how to do that in Yii2.

I used this function in Yii 1:

Yii::app()->clientScript->scriptMap = array(
    'main.css' => false
);

Solution

If you need to disable the CSS specific to core bootstrap in a view then add the following on top of your view file like this

Yii::$app->assetManager->bundles['yii\bootstrap\BootstrapAsset'] = false;

and if you need to disable the bootstrap core js sources also then use

Yii::$app->assetManager->bundles['yii\bootstrap\BootstrapPluginAsset'] = false;


Answered By - Muhammad Omer Aslam
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing