Yii中单独为module加载Bootstrap或其他组件的4种方法
2014-03-06 00:35
363 查看
Bootstrap中包含了丰富的Web组件,根据这些组件,可以快速的搭建一个漂亮、功能完备的网站。
但是有时候我们网站前台并不需要Bootstrap,只要管理后台使用Bootstrap,那么该如何单独为一个module加载Bootstrap呢?
这里有4中方法来实现这个:
1.在应用的配置文件中添加如下内容 (protected/config/main.php):
2.在模块初始化时加载:
3.模块初始化加载的另一种方法:
4.模块加载时的另一种方法:
转载自: 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或…
- Yii扩展组件编写方法实例分析
- android中图片加载的4种途径和加载方法
- angularjs 去往其他页面,目标页面controller中的方法无法自动加载
- 在Arcmap中加载互联网地图资源的4种方法
- Yii2 自动加载,依赖注入,获取实例,动态调用方法
- yii加载自带验证码的方法
- BootStrap下的弹出框加载select2框架失败的解决方法
- 使用COM或者OLE的方法调用来控制Excel或者其他Office组件
- Bootstrap滚动监听组件scrollspy.js使用方法详解
- 四大组件之Activity——组件间传递数据的4种常用方法
- 在Arcmap中加载互联网地图资源的4种方法
- vue引入其他框架组件方法汇总
- 动态加载JS脚本的4种方法
- IIS使用 URL Rewrite Module 2.0组件 设置伪静态的方法
- 动态加载JS脚本的4种方法
- java动态加载指定的类或者jar包反射调用其方法-涉及其他jar中的类就报ClassNotFound问题分析及解决思路
- 未能从程序集“System.ServiceModel, Version=3.0.0.0”中加载类型“System.ServiceModel.Activation.HttpModule” 的错误解决方法