Direction Target
分类: Web开发
2015-07-12 19:16:52
1. 解压yiistrap-master.zip重命名为bootstrap 放到protected\extensions\目录下
protected
└── extensions
└── bootstrap
├── assets
│ ├── css
│ ├── img
│ ├── js
│ └── less
├── behaviors
├── components
├── gii
├── helpers
└── widgets
2.配置 protected/config/main.php
<?php
// main configuration
return array(
...
// path aliases
'aliases' => array(
...
// 'bootstrap' => realpath(__DIR__ . '/../extensions/bootstrap'), // change this if necessary
'bootstrap' => dirname(__FILE__) . '/../extensions/bootstrap', //根据bootstrap位置而定
),
// import paths
'import' => array(
...
'bootstrap.helpers.TbHtml',
),
// application modules
'modules' => array(
...
'gii' => array(
...
'generatorPaths' => array('bootstrap.gii'),
),
),
// application components
'components' => array(
...
'bootstrap' => array(
'class' => 'bootstrap.components.TbApi',
),
),
);
3.视图注册bootstrap protected/views/layouts/main.php文件开始添加
<?php Yii::app()->bootstrap->register(); ?>
4.测试某一视图中
<?php $this->widget('bootstrap.widgets.TbDetailView', array(
'data'=>array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'),
'attributes'=>array(
array('name'=>'firstName', 'label'=>'First name'),
array('name'=>'lastName', 'label'=>'Last name'),
array('name'=>'language', 'label'=>'Language'),
),
)); ?>