Home > Article > Backend Development > 4 ways to load Bootstrap or other components separately for modules in Yii_PHP Tutorial
Bootstrap contains a wealth of web components. Based on these components, you can quickly build a beautiful and fully functional website. But sometimes we don’t need Bootstrap in the frontend of our website. We only need to use Bootstrap in the management backend. So how do we load Bootstrap for a module separately?
Here are 4 ways to achieve this:
1. Add the following content to the application configuration file (protected/config/main.php):
PHP
The code is as follows | Copy code | ||||||||
'modules'=>array(
'preload'=>array('bootstrap'), 'components'=>array('bootstrap'=>array( ‘class’=>’ext.bootstrap.components.Bootstrap’
|
The code is as follows | Copy code |
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 module initialization loading:
The code is as follows
|
Copy code
|
||||
PHP
|
{
'admin.components.*',
The code is as follows | Copy code |
PHP 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(); } http://www.bkjia.com/PHPjc/631525.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631525.htmlTechArticleBootstrap contains a wealth of Web components. Based on these components, you can quickly build a beautiful and fully functional website. . But sometimes we don’t need Bootstrap at the front end of our website, we just... |