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 $this->configure(array( |
|
4.模块加载时的另一种方法:
| 代码如下 | 复制代码 |
|
php $this->configure(array( |
|
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号