2.0.x LESS and registered CSS

95 views
Skip to first unread message

Justin Voelker

unread,
Jan 21, 2013, 5:02:18 PM1/21/13
to yii-bo...@googlegroups.com
In previous versions I was able to add the following to my config:

'coreCss'=>false,
'responsiveCss'=>false,
'yiiCss'=>false,

and then include my own customized bootstrap stylesheets in my layout:

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/themes/default/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/themes/default/css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/themes/default/css/bootstrap-yii.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/themes/default/css/styles.css" />

Trying to add those key=>values to my config returns an exception error stating that those properties are not defined.  This definitely appears to be something new in 2.0.x so how do I go about instructing bootstrap to not include css so I can include my own?

Christoffer Niska

unread,
Jan 21, 2013, 5:06:53 PM1/21/13
to yii-bo...@googlegroups.com
Yes, it has been mentioned a number of time but I'll mention it again.

In Yii-Bootstrap 2.0.x the need for preloading the component was dropped because it caused problems.
Now you need to register the CSS and JS yourself in your layout. To do this you can use a number of public methods in the Bootstrap class.
If you just wish to register all files you can use the registerAll() method but there are also methods for registering each file separately.

In your case you probably want to use registerYiiCss() and registerCoreScripts().

-Chris
--
Best regards,
Christoffer Niska
Phone +358 500 980 565

Justin Voelker

unread,
Jan 21, 2013, 5:21:22 PM1/21/13
to yii-bo...@googlegroups.com
Thank you for the extremely prompt reply Chris.  I have seen other posts regarding the preloading but still was not sure how to actually use my own css.  Now seeing the methods you reference I can see in the layout file that "register" is being called which registers the css and core scripts.  Somehow I had completely missed this in my endless search for "how is the CSS being include?"

I removed "Yii::app()->bootstrap->register()" from the theme and replaced it with merely "Yii::app()->bootstrap->registerCoreScripts()" so that I could include all of my own css.

Thanks again, Chris.  I just needed that little extra pointer to see what I was otherwise completely missing.

Christoffer Niska

unread,
Jan 21, 2013, 5:48:02 PM1/21/13
to yii-bo...@googlegroups.com
No problem,

For a setup with LESS you can take a look at my new Yii template application on GitHub:
Reply all
Reply to author
Forward
0 new messages