Browse Source

Multilevel Items

tags/2.0.0-beta
Mojtaba Salehi 12 years ago
parent
commit
95b1636a98
  1. 24
      framework/yii/bootstrap/Nav.php

24
framework/yii/bootstrap/Nav.php

@ -27,13 +27,19 @@ use yii\helpers\Html;
* ), * ),
* array( * array(
* 'label' => 'Dropdown', * 'label' => 'Dropdown',
* 'dropdown' => array( * 'items' => array(
* array( * array(
* 'label' => 'DropdownA', * 'label' => 'Level 1 -DropdownA',
* 'url' => '#', * 'url' => '#',
* 'items' => array(
* array(
* 'label' => 'Level 2 -DropdownA',
* 'url' => '#',
* ),
* ),
* ), * ),
* array( * array(
* 'label' => 'DropdownB', * 'label' => 'Level 1 -DropdownB',
* 'url' => '#', * 'url' => '#',
* ), * ),
* ), * ),
@ -114,7 +120,7 @@ class Nav extends Widget
} }
$label = $this->encodeLabels ? Html::encode($item['label']) : $item['label']; $label = $this->encodeLabels ? Html::encode($item['label']) : $item['label'];
$options = ArrayHelper::getValue($item, 'options', array()); $options = ArrayHelper::getValue($item, 'options', array());
$dropdown = ArrayHelper::getValue($item, 'dropdown'); $items = ArrayHelper::getValue($item, 'items');
$url = Html::url(ArrayHelper::getValue($item, 'url', '#')); $url = Html::url(ArrayHelper::getValue($item, 'url', '#'));
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array()); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
@ -122,19 +128,19 @@ class Nav extends Widget
$this->addCssClass($options, 'active'); $this->addCssClass($options, 'active');
} }
if ($dropdown !== null) { if ($items !== null) {
$linkOptions['data-toggle'] = 'dropdown'; $linkOptions['data-toggle'] = 'dropdown';
$this->addCssClass($options, 'dropdown'); $this->addCssClass($options, 'dropdown');
$this->addCssClass($urlOptions, 'dropdown-toggle'); $this->addCssClass($urlOptions, 'dropdown-toggle');
$label .= ' ' . Html::tag('b', '', array('class' => 'caret')); $label .= ' ' . Html::tag('b', '', array('class' => 'caret'));
if (is_array($dropdown)) { if (is_array($items)) {
$dropdown = Dropdown::widget(array( $items = Dropdown::widget(array(
'items' => $dropdown, 'items' => $items,
'clientOptions' => false, 'clientOptions' => false,
)); ));
} }
} }
return Html::tag('li', Html::a($label, $url, $linkOptions) . $dropdown, $options); return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options);
} }
} }

Loading…
Cancel
Save