在YII框架中添加BOOTSTRAP組件

1.下載yii-bootstrap 下載地址 http://ttp://phpwl.ueware.com/wp-content/uploads/2015/06/yii-bootstrap.zip
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'=>'#'),
                    )
                ),
            ),
        ),
    ),
)); 
?>
相關文章
相關標籤/搜索