码迷,mamicode.com
首页 > 其他好文 > 详细

yii框架中cMenu的使用

时间:2015-11-04 14:51:00      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

最近在使用yii框架的时候,想做一个头部导航的分类,因为在开发的时候,考虑到了要兼容移动端,所以,内嵌了bootstrap,其实,yii在处理分类,多级分类的时候还是挺简单的,下面就让我们看看具体的一个例子吧:

        <nav class="navbar navbar-default" role="navigation">
               <div class="navbar-header">
                          <button type="button" class="navbar-toggle" data-toggle="collapse" 
                             data-target="#example-navbar-collapse">
                             <span class="sr-only">切换导航</span>
                             <span class="icon-bar"></span>
                             <span class="icon-bar"></span>
                             <span class="icon-bar"></span>
                          </button>
                          <div class="navbar-brand visible-xs">                       
                             <a href="/" rel="nofollow">Home</a> | 
                             <a href="" rel="nofollow">Creat My Trip</a>
                   </div>
                    </div>
               <div class="collapse navbar-collapse" id="example-navbar-collapse">
                        <?php 
                            $this->widget(‘zii.widgets.CMenu‘, array(
                                ‘activeCssClass‘=>‘activeli‘,
                                ‘firstItemCssClass‘=>‘fistli‘, 
                                ‘lastItemCssClass‘=>‘lastli‘, 
                                ‘encodeLabel‘    =>false,
                                ‘htmlOptions‘=>array(‘class‘=>‘nav navbar-nav‘),
                                ‘submenuHtmlOptions‘    =>array(‘class‘=>‘dropdown-menu‘),

                                ‘items‘=>array(
                                    array(‘label‘=>‘china tours‘, ‘url‘=>array(‘site/index‘),‘itmeOptions‘=>array(‘id‘=>‘China tours‘)),//為li添加id
                                    array(‘label‘=>‘destinations‘, ‘url‘=>array(‘site/contact‘),‘itemOptions‘=>array(‘class‘=>‘dropdown‘),//‘linkOptions‘=>array(‘class‘=>‘dropdown-toggle‘,‘data-toggle‘=>‘dropdown‘),
                                        ‘items‘=>array(
                                            array(‘label‘=>‘New Arrivals‘, ‘url‘=>array(‘product/new‘, ‘tag‘=>‘new‘)),
                                            array(‘label‘=>‘Most Popular‘, ‘url‘=>array(‘product/index‘, ‘tag‘=>‘popular‘)),
                                            )
                                    ),
                                array(‘label‘=>‘heritage tours‘, ‘url‘=>array(‘site/login‘),‘itemOptions‘=>array(‘class‘=>‘dropdown‘),
                                    ‘items‘=>array(
                                        array(‘label‘=>‘New Arrivals 1‘, ‘url‘=>array(‘product/new‘, ‘tag‘=>‘new‘)),
                                        array(‘label‘=>‘Most Popular 1‘, ‘url‘=>array(‘product/index‘, ‘tag‘=>‘popular‘)),
                                    ),
                                    
                                    ‘visible‘=>Yii::app()->user->isGuest
                                    ),
                                array(‘label‘=>‘shore excursions‘, ‘url‘=>array(‘site/index‘),‘itmeOptions‘=>array(‘id‘=>‘shore excursions‘)),
                                ),
                            ));
                        ?>
                    </div>
        </nav> 


用过bootstrap的人都知道,这样写的目的。先记录一下,以后也许会用到吧

 

yii框架中cMenu的使用

标签:

原文地址:http://www.cnblogs.com/zouxiaoyang1219/p/4935844.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!