bootstrap中包含了丰富的web组件,根据这些组件,可以快速的搭建一个漂亮、功能完备的网站。但是有时候我们网站前台并不需要bootstrap,只要管理后台使用bootstrap,那么该如何单独为一个module加载bootstrap呢
这里有4中方法来实现这个:
1.在应用的配置文件中添加如下内容 (protected/config/main.php):
php
代码如下 复制代码
'modules'=>array(
'admin'=>array(
'preload'=>array('bootstrap'),
'components'=>array(
'bootstrap'=>array(
'class'=>'ext.bootstrap.components.bootstrap'
)
),
// ...其他模块...
)
2.在模块初始化时加载:
代码如下 复制代码
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.模块初始化加载的另一种方法:
代码如下 复制代码
php
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.模块加载时的另一种方法:
代码如下 复制代码
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中包含了丰富的web组件,根据这些组件,可以快速的搭建一个漂亮、功能完备的网站。但是有时候我们网站前台并不需要bootstrap,只...
