How to put the * Bootstrap ('glyphicon-bootstrap') icons in the Yii framework menu

2

I'm starting a project at the company where I develop, and we're thank you for using the Yii Framework along with Bootstrap , but I'm not you can put the Bootstrap ( glyphicon-bootstrap ) icons in the menu, follow the code example:

$this->widget('zii.widgets.CMenu',
   array('htmlOptions'=>array("class"=>"nav", "id"=>"side-menu"), 'items'=>array(
        array('label'=>'Home', 'url'=>array('/site/index')),
        array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
        array('label'=>'Contact', 'url'=>array('/site/contact'), 'className '=>'tafaera'),
        array('label'=>'Charts', 'url'=>array('/submenu/sub0'),
            'submenuOptions'=>array('class'=>'nav nav-second-level'),
            'items'=>array(
                    array('label'=>'Sub 1.1','tag'=>'tafarel' ,'url'=>array('/submenu/sub1')),
                    array('label'=>'Sub 1.2', 'url'=>array('/submenu/sub2')),
                    array('label'=>'Sub 1.3','url'=>array('/submenu/sub3')
                )
            )
        ),
        array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
        array('label'=>'Hola', 'url'=>array('/hola/index')),
        array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
    ),
));

    
asked by anonymous 07.07.2014 / 15:18

1 answer

1

Put this option 'encodeLabel'=>false , same example below.

$this->widget('zii.widgets.CMenu', 
     array('encodeLabel'=>false, ....

In your code:

$this->widget('zii.widgets.CMenu',
   array("encodeLabel"=>false, 'htmlOptions'=>array("class"=>"nav", "id"=>"side-menu"), 'items'=>array(
        array('label'=>'<i class=""></i> Home', 'url'=>array('/site/index')),
        array('label'=>'<i class=""></i> About', 'url'=>array('/site/page', 'view'=>'about')),
        array('label'=>'<i class=""></i> Contact', 'url'=>array('/site/contact'), 'className '=>'tafaera'),
        array('label'=>'<i class=""></i> Charts', 'url'=>array('/submenu/sub0'),
            'submenuOptions'=>array('class'=>'nav nav-second-level'),
            'items'=>array(
                    array('label'=>'Sub 1.1','tag'=>'tafarel' ,'url'=>array('/submenu/sub1')),
                    array('label'=>'Sub 1.2', 'url'=>array('/submenu/sub2')),
                    array('label'=>'Sub 1.3','url'=>array('/submenu/sub3')
                )
            )
        ),
        array('label'=>'<i class=""></i> Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
        array('label'=>'<i class=""></i> Hola', 'url'=>array('/hola/index')),
        array('label'=>'<i class=""></i> Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
    ),
));

In this Link - How do I add image into CMenu , has the explanation of some users

    
07.07.2014 / 15:47