我创建一个菜单,如一个带有CMenu小部件的Twitter Bootstrap导航栏:
<?PHP $this->widget( 'zii.widgets.CMenu',array( 'items' => array( array( 'label' => 'Home','url' => array( '/site/index' ),),array( 'label' => 'Dropdown <b class="caret"></b>','url' => '#','submenuOptions' => array( 'class' => 'dropdown-menu' ),'items' => array( array( 'label' => 'Submenu Item 1','url' => array( '/user/create' ),array( 'label' => 'Submenu Item 1','url' => array( '/user/list' ),'itemOptions' => array( 'class' => 'dropdown' ),'linkOptions' => array( 'class' => 'dropdown-toggle','data-toggle' => 'dropdown' ),'htmlOptions' => array( 'class' => 'nav' ),)); ?>
此代码生成菜单,其中有2个项目,第二个菜单项有1个子菜单.精细.但只有事情不起作用就是’label’=> ‘dropdown< b class =“caret”>< / b>‘,在第9行.它呈现为Dropdown& lt; b class =& quot; caret& quot;& gt;& lt; / b& gt;在页面上所以我看到标题’Dropdown< b class =“caret”>< / b>‘而不是下拉▼.
感谢您的关注.
您必须将
CMenu
的
encodeLabel
属性设置为false
<?PHP $this->widget('zii.widgets.CMenu',array( 'encodeLabel' => false,'htmlOptions' => array('class' => 'nav'),'items' => array( array( 'label' => 'Home','url' => array('/site/index'),array( 'label' => 'Dropdown <b class="caret"></b>','submenuOptions' => array('class' => 'dropdown-menu'),'items' => array( array( 'label' => 'Submenu Item 1','url' => array('/user/create'),array( 'label' => 'Submenu Item 1','url' => array('/user/list'),'itemOptions' => array('class' => 'dropdown'),'linkOptions' => array('class' => 'dropdown-toggle','data-toggle' => 'dropdown'),)); ?>