/** * Renders menu items. * @param array $items the menu items to be rendered * @return string the rendering result. * @throws InvalidConfigException if the label option is not specified in one of the items. */ protected function renderItems($items) { if ($this->tag) { Html::addCssClass($this->itemsOptions, 'uk-nav-dropdown'); } if (is_array($items)) { return Nav::widget(['options' => $this->itemsOptions, 'items' => $items]); } return $items; }
/** * Renders a widget's item. * @param string|array $item the item to render. * @return string the rendering result. * @throws InvalidConfigException */ public function renderItem($item) { if (is_string($item)) { return Html::tag('li', $item, []); } if (!isset($item['label'])) { throw new InvalidConfigException("The 'label' option is required."); } $label = $this->encodeLabels ? Html::encode($item['label']) : $item['label']; $options = ArrayHelper::getValue($item, 'options', []); $items = ArrayHelper::getValue($item, 'items'); $url = ArrayHelper::getValue($item, 'url', false); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); if (isset($item['active'])) { $active = ArrayHelper::remove($item, 'active', false); } else { $active = $this->isItemActive($item); } if ($active) { Html::addCssClass($options, 'uk-active'); } if ($items !== null) { if (is_array($items)) { $options = array_merge(['data-uk-dropdown' => $this->hoverMode ? '' : "{mode:'click'}"], $options); $items = Html::tag('div', Nav::widget(['items' => $items, 'options' => ['class' => 'uk-nav-dropdown']]), ['class' => 'uk-dropdown uk-dropdown-small']); } } $link = $label; if ($url) { $link = Html::a($label, $url, $linkOptions); } return Html::tag('li', $link . $items, $options); }