简体   繁体   中英

Yii CMenu Third Level not showing

I'm trying to use Yii's CMenu widget. The array of menu items is being generated by class I wrote which extracts data from tbl_menu in the database. As far as I can tell the array has been generated fine. (See end of post for a section of it)

The menu is created, all the HTML of all levels and items is there. The second level shows when a parent from level 1 is clicked, but not the third level when a parent from level two is clicked.

Widget Code

$modelMenu = new TblMenu();         

$this->widget('zii.widgets.CMenu',array(
                'htmlOptions'=>array('class'=>'pull-right nav'),
                'submenuHtmlOptions'=>array('class'=>'dropdown-menu'),
                'itemCssClass'=>'item-test',
                'encodeLabel'=>false,
                'items'=>$modelMenu->getMenu() //returns the Menu array (as seen below)
                ));

Menu Array

array(6) {
  [0]=>
   array(5) {
   ["label"]=> string(40) "Control Panel"
    ["url"]=>  string(1) "#"
    ["itemOptions"]=>
    array(2) {
      ["class"]=>
      string(8) "dropdown"
      ["tabindex"]=>
      string(2) "-1"
    }
    ["linkOptions"]=>
    array(2) {
      ["class"]=>  string(15) "dropdown-toggle"
      ["data-toggle"]=>  string(8) "dropdown"
    }
    ["items"]=>
    array(6) {
      [0]=>
      array(5) {
        ["label"]=>  string(40) "Basic Setting"
        ["url"]=>  string(1) "#"
        ["itemOptions"]=>
        array(2) {
          ["class"]=> string(8) "dropdown"
          ["tabindex"]=>  string(2) "-1"
        }
        ["linkOptions"]=>
        array(2) {
          ["class"]=> string(15) "dropdown-toggle"
          ["data-toggle"]=>  string(8) "dropdown"
        }
        ["items"]=>
        array(8) {
          [0]=>
          array(5) {
            ["label"]=>  string(33) "County"
            ["url"]=>    string(1) "#"
            ["itemOptions"]=>
            array(2) {
              ["class"]=>  string(8) "dropdown"
          ["tabindex"]=> string(2) "-1"
        }
        ["linkOptions"]=>
        array(2) {
          ["class"]=> string(15) "dropdown-toggle"
          ["data-toggle"]=> string(8) "dropdown"
        }
        ["items"]=>
        array(2) {
          [0]=>
          array(2) {
            ["label"]=> string(7) "Add New"
            ["url"]=> string(82) "http://www.link.co.uk/to/menu/item"
          }
          [1]=>
          array(2) {
            ["label"]=> string(9) "View List"
            ["url"]=> string(83) "http://www.link.co.uk/to/menu/item"
          }
        }
      }
....TRUNCATED DUE TO LENGTH

I managed to get around this issue by using the jqueryslidemenu plugin.

See here: Yii Framework Forum - CMenu and Multilevel nested menu

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM