Yii Framework Forum: Change id or add css class to ul having dropdown-menu of Yiistarp TbNav widget - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Change id or add css class to ul having dropdown-menu of Yiistarp TbNav widget Rate Topic: -----

#1 User is offline   gopi_patel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-July 16

Posted 10 October 2017 - 10:50 PM

I have below code to create navigation menu using YiiStrap widget Tbnav .

$this->widget('TbNav', array(
    'htmlOptions' => array(
        'class' => 'navbar-left',
        'id' => 'category-menu'
    ) ,
    'encodeLabel' => false,
    'activateItems' => false,
    'items' => array(
        array(
            'htmlOptions' => [
                'class' => 'submenu-bar',
                'id' => 'main-nav'
             ],
            'activateParents' => true,
            'label' => '<span class="glyphicon glyphicon-th" style="margin-right:5px;"></span> Categories',
            'items' => array_merge(
               array(
                array(
                    'label' => 'Browse All',
                    'url' => array('mylink/all')
                ) ,
                TbHtml::menuDivider()
               ) , 
               array(
                array(
                    'label' => 'Category 1',
                    'url' => array('list/cat1')
                )
               ), 
               array(
                array(
                    'label' => 'Category 2',
                    'url' => array('list/cat2')
                )
               )
              ) ,
            ) ,
      ) ,
));


And it generates below HTML code


<ul role="menu" id="category-menu" class="navbar-left nav navbar-nav">
<li role="menuitem" activateparents="1" id="main-nav" class="submenu-bar dropdown"><a href="" data-toggle="dropdown" class="dropdown-toggle"><span style="margin-right:5px;" class="glyphicon glyphicon-th"></span> Categories <b class="caret"></b></a>
    <ul role="menu" aria-labelledby="yt0" id="yt0" class="dropdown-menu">
        <li role="menuitem"><a href="/mylink/all" tabindex="-1">Browse All</a></li>
        <li class="divider"></li>
        <li role="menuitem"><a href="/list/cat1" tabindex="-1">Category 1</a></li>
        <li role="menuitem"><a href="/list/cat2" tabindex="-1">Category 2</a></li>
    </ul>
</li>


How can i change id or add class to ul element having class="dropdown-menu".

<ul role="menu" aria-labelledby="yt0" id="yt0" class="dropdown-menu">

I have tried adding submenuHtmlOptions but it gives me error .
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users