Yii中单独为module加载Bootstrap或其他组件的4种方法
2014-08-20 17:20
369 查看
Bootstrap中包含了丰富的Web组件,根据这些组件,可以快速的搭建一个漂亮、功能完备的网站。
但是有时候我们网站前台并不需要Bootstrap,只要管理后台使用Bootstrap,那么该如何单独为一个module加载Bootstrap呢?
这里有4中方法来实现这个:
1.在应用的配置文件中添加如下内容 (protected/config/main.php):
'modules'=>array(
'admin'=>array(
'preload'=>array('<span class='wp_keywordlink_affiliate'><a href="http://lxy.me/tag/bootstrap" title="查看bootstrap中的全部文章" target="_blank">bootstrap</a></span>'),
'components'=>array(
'<span class='wp_keywordlink_affiliate'><a href="http://lxy.me/tag/bootstrap" title="查看bootstrap中的全部文章" target="_blank">bootstrap</a></span>'=>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.模块初始化加载的另一种方法:
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.模块加载时的另一种方法:
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://lxy.me/yii-separate-module-load-components.html
但是有时候我们网站前台并不需要Bootstrap,只要管理后台使用Bootstrap,那么该如何单独为一个module加载Bootstrap呢?
这里有4中方法来实现这个:
1.在应用的配置文件中添加如下内容 (protected/config/main.php):
'modules'=>array(
'admin'=>array(
'preload'=>array('<span class='wp_keywordlink_affiliate'><a href="http://lxy.me/tag/bootstrap" title="查看bootstrap中的全部文章" target="_blank">bootstrap</a></span>'),
'components'=>array(
'<span class='wp_keywordlink_affiliate'><a href="http://lxy.me/tag/bootstrap" title="查看bootstrap中的全部文章" target="_blank">bootstrap</a></span>'=>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.模块初始化加载的另一种方法:
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.模块加载时的另一种方法:
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://lxy.me/yii-separate-module-load-components.html
相关文章推荐
- Yii中单独为module加载Bootstrap或其他组件的4种方法
- Yii中单独为module加载Bootstrap或…
- 动态加载JS脚本的4种方法[转自http://hi.baidu.com/ajax] http://www.cnitblog.com/yemoo/archive/2007/07/19/30222.html
- 动态加载JS脚本的4种方法
- 错误:“未安装全文搜索或无法加载某一全文组件”的解决方法
- 要实现动态加载JS脚本有4种方法
- ExtJS中TabPanel用iframe加载其他完整页面的处理方法
- 动态加载JS脚本的4种方法
- 动态加载JS脚本的4种方法
- 动态加载JS的4种方法
- 动态加载JS脚本的4种方法
- VS2008试用版 怎样升级到正式版,以及组件加载失败解决方法
- 嵌入式Linux2.6 Kernel Module模板动态加载实例和常见问题解决方法
- 动态加载JS脚本的4种方法
- JS 动态加载脚本的4种方法
- 错误:“未安装全文搜索或无法加载某一全文组件”的解决方法
- 要实现动态加载JS脚本有4种方法:
- flex chart 上添加其他组件的方法。
- 要实现动态加载JS脚本有4种方法
- 动态加载JS脚本的4种方法