1.下载<a href="http://phpwl.ueware.com/wp-content/uploads/2015/06/yii-bootstrap.zip">yii-bootstrap</a>
2.解压后将文件修改名字为bootstrap并拷贝到项目protected/extensions下
3.修改配置文件main.php
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');/*定义别名*/
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
'generatorPaths'=>array( //添加一个gii检索的路径
'bootstrap.gii',
),
),
'components'=>array(
'bootstrap'=>array(//添加一个新的bootstrap容器
'class'=>'bootstrap.components.Bootstrap', //执行Bootstrap.php文件
),
4.修改view /views/layouts/main.php
在header里面添加<?php Yii::app()->bootstrap->register(); ?>/*将所有bootstrap中的文件导入*/
demo:菜单
<?php $this->widget('bootstrap.widgets.TbNavbar', array(
'items'=>array(
array(
'class'=>'bootstrap.widgets.TbMenu',
'items'=>array(
array(
'encodeLabel'=>false,
'linkOptions'=> array('encode'=>false),
'label'=> '首页',
'url'=>'',
'items'=>array(
array('label'=>'Account info', 'url'=>'#'),
'---',
array('label'=>'Logout', 'url'=>'#'),
)
),
),
),
),
));
?>
转载于:https://my.oschina.net/u/234439/blog/472144