Bootstrap contains a wide range of web components. Based on these components, you can quickly build a beautiful and fully functional website.
But sometimes we do not need Bootstrap at the front end of our website. As long as Bootstrap is used in the management background, how can we load Bootstrap for a module separately?
Here are 4 methods to implement this:
1. Add the following content (protected/config/Main. php) to the application configuration file ):
'Modules' => array ('admin' => array ('preload' => array ('<SPAN class = 'wp _ keywordlink_affiliate'> <a href = "http://lxy.me/tag/bootstrap" title = "view all articles in Bootstrap" target = "_ blank"> Bootstrap </a> </span> '), 'components' => array ('<SPAN class = 'wp _ keywordlink_affiliate'> <a href = "http://lxy.me/tag/bootstrap" Title = "view all articles in Bootstrap" target = "_ blank"> Bootstrap </a> </span> '=> array ('class' => 'ext. bootstrap. components. bootstrap ')),//... other modules ...)
2. Load During module initialization:
public function init() { // import the module-level models and components $this->setImport(array( ‘admin.models.*‘, ‘admin.components.*‘, // ‘ext.bootstrap.components.Bootstrap‘, // this will go to app config for components )); Yii::app()->getComponent(‘bootstrap‘);// this does the loading }
3. Another method for initialization and loading of modules:
public function init() { // import the module-level models and components $this->setImport(array( ‘admin.models.*‘, ‘admin.components.*‘, )); $this->configure(array( ‘components‘=>array( ‘bootstrap‘=>array( ‘class‘=>‘ext.bootstrap.components.Bootstrap‘ ) ) )); $this->getComponent(‘bootstrap‘); }
4. Another method for Loading modules:
public function init() { // import the module-level models and components $this->setImport(array( ‘admin.models.*‘, ‘admin.components.*‘, )); $this->configure(array( ‘preload‘=>array(‘bootstrap‘), ‘components‘=>array( ‘bootstrap‘=>array( ‘class‘=>‘ext.bootstrap.components.Bootstrap‘ ) ) )); $this->preloadComponents(); }