Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii Bootstrap does not work if not preloaded

I have been using Yii Bootstrap in an application for a while. Now, I have a section where the loaded CSS files are causing issues, and I don't want to load the bootstrap extension in that controller.

In my configuration file, I had bootstrap set to preload:

'preload' => array('log', 'bootstrap')

I have now removed bootstrap from the preload array, and it stops working saying the alias is incorrect:

Alias "bootstrap.widgets.BootNavbar" is invalid. Make sure it points to an existing directory or file.

The alias though has been defined in the components section of the configuration file and works fine when the bootstrap component is preloaded:

'bootstrap' => array(
    'class' => 'ext.bootstrap.components.Bootstrap'
 ),

What can I do to make the bootstrap extension work without preloading it?

like image 742
HyderA Avatar asked Jul 23 '12 12:07

HyderA


1 Answers

Just call this:

Yii::app()->getComponent("bootstrap");

'preload' => 'bootstrap' actually trigers this command. If you just call Yii::app()->bootstrap->init() as suggested by Blizz you will end up calling init() twice, which could be harmful.

like image 115
Cangussu Avatar answered Sep 22 '22 10:09

Cangussu