For example:
php
echo Nav::widget([
'items' => [
[
'label' => 'Home',
'url' => ['site/index'],
'linkOptions' => [...],
],
[
'label' => 'Dropdown',
'items' => [
['label' => 'Level 1 - Dropdown A', 'url' => '#'],
'',
'Dropdown Header ',
['label' => 'Level 1 - Dropdown B', 'url' => '#'],
],
],
[
'label' => 'Login',
'url' => ['site/login'],
'visible' => Yii::$app->user->isGuest
],
],
'options' => ['class' =>'nav-pills'], // set this to nav-tab to get tab-styled navigation
]);
Note: Multilevel dropdowns beyond Level 1 are not supported in Bootstrap 3.
public function getMenu() { $isAdmin = !Yii::$app->user->isGuest ? Yii::$app->user->identity->can('editor') : false; $canAdmin = !Yii::$app->user->isGuest ? Yii::$app->user->identity->can('editor') : false; $networksVisible = count(Yii::$app->authClientCollection->clients) > 0; $menuItems = [['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], ['label' => 'Contact', 'url' => ['/site/contact']]]; if (Yii::$app->user->isGuest) { $menuItems[] = ['label' => Yii::t('user', 'Sign up'), 'url' => ['/user/registration/register']]; $menuItems[] = ['label' => Yii::t('user', 'Sign in'), 'url' => ['/user/security/login']]; } else { $menuItems['user'] = ['label' => $isAdmin ? Yii::$app->user->identity->profile->fullname . ' (admin)' : Yii::$app->user->identity->profile->fullname, 'items' => [['label' => Yii::t('user', 'Profile'), 'url' => ['/user/settings/profile']], ['label' => Yii::t('user', 'Account'), 'url' => ['/user/settings/account']], ['label' => Yii::t('user', 'Networks'), 'url' => ['/user/settings/networks'], 'visible' => $networksVisible], '<li class="divider"></li>', ['label' => Yii::t('user', 'Logout'), 'url' => ['/user/security/logout'], 'linkOptions' => ['data-method' => 'post']]]]; } if ($canAdmin) { $menuItems['user']['items'][] = '<li class="divider"></li>'; $menuItems['user']['items'][] = ['label' => Yii::t('user', 'Admin Panel'), 'url' => Yii::$app->urlManagerBackEnd->createUrl('')]; } NavBar::begin(['brandLabel' => Yii::$app->params['companyName'], 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]); NavBar::end(); }
/** * Initialize the widget * @throws InvalidConfigException */ public function init() { if (!class_exists($this->dropdownClass)) { throw new InvalidConfigException("The dropdownClass '{$this->dropdownClass}' does not exist or is not accessible."); } parent::init(); }
/** * @inheritdoc */ public function init() { parent::init(); $userModuleClass = 'dektrium\\user\\Module'; $isUserModuleInstalled = \Yii::$app->getModule('user') instanceof $userModuleClass; $this->items = [['label' => \Yii::t('rbac', 'Users'), 'url' => ['/user/admin/index'], 'visible' => $isUserModuleInstalled], ['label' => \Yii::t('rbac', 'Roles'), 'url' => ['/rbac/role/index']], ['label' => \Yii::t('rbac', 'Permissions'), 'url' => ['/rbac/permission/index']], ['label' => \Yii::t('rbac', 'Rules'), 'url' => ['/rbac/rule/index']], ['label' => \Yii::t('rbac', 'Create'), 'items' => [['label' => \Yii::t('rbac', 'New user'), 'url' => ['/user/admin/create'], 'visible' => $isUserModuleInstalled], ['label' => \Yii::t('rbac', 'New role'), 'url' => ['/rbac/role/create']], ['label' => \Yii::t('rbac', 'New permission'), 'url' => ['/rbac/permission/create']], ['label' => \Yii::t('rbac', 'New rule'), 'url' => ['/rbac/rule/create']]]]]; }
protected function isItemActive($item) { if (isset($item['url']) && is_string($item['url']) && $item['url'] === Url::current()) { return true; } return parent::isItemActive($item); }
protected function renderDropdown($items, $parentItem) { foreach ($items as &$item) { $this->changeItem($item); } return parent::renderDropdown($items, $parentItem); }
public function init() { parent::init(); try { $tableSchema = Yii::$app->db->schema->getTableSchema(MenuItem::tableName()); } catch (\yii\db\Exception $e) { } if (empty($tableSchema)) { return; } $models = MenuItem::find()->where(['menu_id' => $this->menu])->orderBy(['order_id' => SORT_ASC])->all(); $items = []; // top menu items foreach ($models as $model) { if ($model->parent_id == 0) { $items[$model->id] = ['label' => $model->title, 'url' => $this->parseRoute($model->route)]; } } foreach ($models as $model) { if (isset($items[$model->parent_id])) { $items[$model->parent_id]['items'][] = ['label' => $model->title, 'url' => $this->parseRoute($model->route)]; } } $this->items = ArrayHelper::merge($items, $this->items); if (Yii::$app->user->identity && Yii::$app->user->identity->getIsAdmin()) { $this->items[] = ['label' => 'Admin Panel', 'url' => '/admin']; } }
public function run() { $user = User::findOne(Yii::$app->user->id); echo Nav::widget(['items' => [['label' => 'Контактная информация', 'url' => ['/tor/profile']], ['label' => 'Добавить лот на продажу', 'url' => ['/tor/mng-ad']], ['label' => 'Мои объявления <span class="badge">' . TorAds::find()->count() . '</span>', 'url' => ['/tor/my-ads']], ['label' => 'Пополнить баланс ', 'url' => ['/']], ['label' => 'История платежей', 'url' => ['/']], ['label' => 'Реферальная ссылка', 'url' => ['/']]], 'options' => ['class' => 'account-nav'], 'encodeLabels' => false]); $view = $this->view; NavAsset::register($view); }
public function run() { $chatModel = new \nitm\widgets\models\Replies(['constrain' => ['type' => 'chat']]); $notificationModel = new \nitm\widgets\models\Notification(['constrain' => ['user_id' => \Yii::$app->user->getId()], 'queryOptions' => ['read' => 0]]); $uniqid = uniqid(); $chatWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-messages-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('comment') . Html::tag('span', $chatModel->hasNew(), ['class' => 'badge']), 'options' => ['class' => !$chatModel->hasNew() ? 'text-disabled' : 'text-success'], 'linkOptions' => ['id' => 'communication-center-messages-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#chat' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#chat' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/reply/index/chat/0', '__format' => 'html', \nitm\widgets\models\Replies::FORM_PARAM => true])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Messages...', ['class' => 'text-center']) . Html::script('$("#communication-center-messages-button' . $uniqid . '").one("mouseover", function (event) { $(this).trigger("click"); })', ['type' => 'text/javascript']), ['role' => 'chatParent', 'id' => 'chat' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]); $alertWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-notifications-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('bell') . Html::tag('span', $notificationModel->count(), ['class' => 'badge']), 'options' => ['class' => !$notificationModel->count() ? 'bg-disabled' : 'bg-success'], 'linkOptions' => ['id' => 'communication-center-notifications-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#communication-center-notifications' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#communication-center-notifications' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/alerts/notifications', '__format' => 'html'])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Alerts...', ['class' => 'text-center']) . Html::script('$("#communication-center-notifications-button' . $uniqid . '").one("mouseover", function (event) { $(this).trigger("click"); })', ['type' => 'text/javascript']), ['id' => 'communication-center-notifications' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]); $widget = $alertWidget . $chatWidget; //$js = "\$nitm.onModuleLoad('communication-center', function (module) { // module.initChatTabs('#".$this->options['id']."'); //});"; $js = ""; if ($this->chatUpdateOptions['enabled']) { $js .= "\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('chat', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\turl: '" . $this->chatUpdateOptions['url'] . "', \r\n\t\t\t\t\tinterval: " . $this->chatUpdateOptions['interval'] . ",\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('replies'), method: 'chatStatus'});\r\n\t\t\t});"; } if ($this->notificationUpdateOptions['enabled']) { $js .= "\r\n\t\t\t\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('notifications', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\tinterval: " . $this->notificationUpdateOptions['interval'] . ",\r\n\t\t\t\t\turl: '" . $this->notificationUpdateOptions['url'] . "',\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('notifications'), method: 'notificationStatus'});\r\n\t\t\t});"; } if ($js) { $js = Html::script($js, ['type' => 'text/javascript']); } return $widget . $js; }
/** * @inheritdoc */ public function init() { if (!$this->authUser instanceof User) { throw new InvalidParamException('AuthUser must be an instance of ' . User::className()); } $this->items = [['url' => ['/user/profile/index'], 'label' => Yii::t('user', 'Common settings')], ['url' => ['/user/profile/vcs-bindings'], 'label' => Yii::t('user', 'VCS bindings')]]; parent::init(); }
/** * @inheritdoc */ public function init() { if (!$this->model instanceof User) { throw new InvalidParamException('Model must be an instance of ' . User::className()); } $this->items = [['url' => ['/user/user-manager/update', 'id' => $this->model->id], 'label' => Yii::t('user', 'Common settings')], ['url' => ['/user/user-manager/vcs-bindings', 'id' => $this->model->id], 'label' => Yii::t('user', 'VCS bindings')]]; parent::init(); }
/** * @inheritdoc * @throws InvalidConfigException */ public function init() { if (!class_exists($this->dropdownClass)) { throw new InvalidConfigException("The dropdownClass '{$this->dropdownClass}' does not exist or is not accessible."); } NavXAsset::register($this->getView()); parent::init(); }
public function init() { parent::init(); $items = []; if (Yii::$app->user->can(User::ROLE_ADMIN)) { $items = Yii::$app->params['menuItems']; } $this->items = $items; }
/** * @inheritdoc */ public function run() { if ($this->direction == 'left') { $this->options['class'] .= ' drop-left'; } $itemTree = $this->generateItemsTree($this->items); $this->items = $this->createItems($itemTree); return parent::run(); }
public function init() { parent::init(); $userId = Yii::$app->user->id; $roles = $userId ? Yii::$app->authManager->getRolesByUser($userId) : []; foreach ($roles as $role) { $items = $this->rolesMenuItems()[$role->name]; $this->items = ArrayHelper::merge($this->items, $items); } }
public function testIds() { Nav::$counter = 0; $out = Nav::widget(['items' => [['label' => 'Page1', 'content' => 'Page1'], ['label' => 'Dropdown1', 'items' => [['label' => 'Page2', 'content' => 'Page2'], ['label' => 'Page3', 'content' => 'Page3']]], ['label' => 'Dropdown2', 'visible' => false, 'items' => [['label' => 'Page4', 'content' => 'Page4'], ['label' => 'Page5', 'content' => 'Page5']]]]]); $expected = <<<EXPECTED <ul id="w0" class="nav"><li><a href="#">Page1</a></li> <li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Dropdown1 <b class="caret"></b></a><ul id="w1" class="dropdown-menu"><li class="dropdown-header">Page2</li> <li class="dropdown-header">Page3</li></ul></li></ul> EXPECTED; $this->assertEqualsWithoutLE($expected, $out); }
/** * @return string */ public function run() { $list = []; list($route, $params) = Yii::$app->getUrlManager()->parseRequest(Yii::$app->getRequest()); $params = ArrayHelper::merge($_GET, $params); $url = isset($params['route']) ? $params['route'] : $route; foreach ($this->languages as $row) { $list = ArrayHelper::merge($list, [['label' => $row['title'], 'url' => Yii::$app->urlManager->createUrl(ArrayHelper::merge($params, [$url, 'language' => $row['iso']]))]]); } return Nav::widget(['options' => $this->options, 'items' => [['label' => Language::getCurrentRecord()->title, 'items' => $list]]]); }
public function init() { parent::init(); $items = []; if (Yii::$app->user->isGuest) { $items[] = ['label' => 'Login', 'url' => ['/admin/default/login']]; } else { $items[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/admin/default/logout'], 'linkOptions' => ['data-method' => 'post']]; } $this->items = $items; }
/** * @inheritdoc */ public function renderItem($item) { if ($this->route === null && Yii::$app->response !== null) { $this->route = Yii::$app->response->getRoute(); } if (isset($item['active'])) { if (is_callable($item['active'])) { $item['active'] = call_user_func($item['active'], $this, $item); } } return parent::renderItem($item); }
/** * Renders mini-toolbar at the end of page body. * * @param \yii\base\Event $event */ public function renderToolbar($event) { /* @var $view View */ /* @var $urlManagerBack \yii\web\UrlManager */ $urlManagerBack = Yii::$app->urlManagerBack; $view = $event->sender; $view->registerCss($view->renderPhpFile(__DIR__ . '/assets/toolbar.min.css')); NavBar::begin(['id' => 'wd-frontend-toolbar', 'brandLabel' => Html::img('@web/img/logo-mini.png'), 'brandUrl' => $urlManagerBack->baseUrl, 'innerContainerOptions' => ['class' => 'container-fluid'], 'options' => ['class' => 'navbar navbar-inverse navbar-fixed-top']]); echo Nav::widget(['encodeLabels' => false, 'options' => ['class' => 'navbar-nav'], 'items' => [['label' => '<span aria-hidden="true" class="glyphicon glyphicon-dashboard"></span> ' . Option::get('sitetitle'), 'items' => [['label' => Yii::t('toolbar', 'Dashboard'), 'url' => $urlManagerBack->baseUrl], ['label' => Yii::t('toolbar', 'Themes'), 'url' => $urlManagerBack->createUrl(['/theme']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Menus'), 'url' => $urlManagerBack->createUrl(['/menu']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Modules'), 'url' => $urlManagerBack->createUrl(['/module']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Widgets'), 'url' => $urlManagerBack->createUrl(['/widget']), 'visible' => Yii::$app->user->can('administrator')]]], ['label' => '<span aria-hidden="true" class="glyphicon glyphicon-plus"></span> ' . Yii::t('toolbar', 'New'), 'items' => $this->getAddNewMenu() ? $this->getAddNewMenu() : null]]]); echo Nav::widget(['encodeLabels' => false, 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => '<span aria-hidden="true" class="glyphicon glyphicon-user"></span> ' . Yii::$app->user->identity->username, 'items' => [['label' => 'Profile', 'url' => $urlManagerBack->createUrl(['/user/profile'])], ['label' => 'Logout', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]]]); NavBar::end(); }
/** * Checks whether a menu item is active. * This is done by checking if [[route]] and [[params]] match that specified in the `url` option of the menu item. * When the `url` option of a menu item is specified in terms of an array, its first element is treated * as the route for the item and the rest of the elements are the associated parameters. * Only when its route and parameters match [[route]] and [[params]], respectively, will a menu item * be considered active. * @param array $item the menu item to be checked * @return boolean whether the menu item is active */ protected function isItemActive($item) { if (isset($item['urlActive']) && is_array($item['urlActive'])) { foreach ($item['urlActive'] as $auxUrl) { $auxItem = $item; $auxItem['url'] = $auxUrl; if (parent::isItemActive($auxItem)) { return true; } } } return parent::isItemActive($item); }
/** * Renders the widget. */ public function run() { // icon support foreach ($this->items as &$item) { if (isset($item['icon'])) { $icon = FA::icon($item['icon']); $item['label'] = trim($icon . ' ' . ArrayHelper::getValue($item, 'label', '')); $item['encode'] = false; unset($item['icon']); } } return parent::run(); }
/** * Initializes the widget. */ public function init() { parent::init(); $this->dropDownCaret = Html::tag('i', '', ['class' => 'fa fa-angle-down']); if ($this->route === null && Yii::$app->controller !== null) { $this->route = Yii::$app->controller->getRoute(); } if ($this->params === null) { $this->params = Yii::$app->request->getQueryParams(); } if ($this->dropDownCaret === null) { } Html::addCssClass($this->options, 'nav'); }
public function run() { $items[] = ['label' => '<span class="sr-only">Вид навигации</span>', 'url' => '#', 'linkOptions' => ['class' => 'sidebar-toggle hidden-xs', 'data-toggle' => 'offcanvas', 'role' => 'button']]; $items[] = ['label' => 'Карта сайта', 'url' => ['/map/index'], 'active' => $this->active_module && $this->active_module->id == 'map' ? true : false]; $modules = \common\models\main\Modules::find()->where(['visible' => 1])->orderBy(['seq' => SORT_ASC])->all(); if ($modules) { $model_items = array(); foreach ($modules as $model) { $model_items[] = ['label' => $model->name, 'url' => [$model->url]]; } $items[] = ['label' => 'Модули', 'items' => $model_items]; } echo Nav::widget(['items' => $items, 'options' => ['class' => 'nav navbar-nav'], 'encodeLabels' => false]); }
public function init() { parent::init(); if (!in_array($this->toggle, [static::TOGGLE_DROPDOWN, static::TOGGLE_COLLAPSE])) { $this->toggle = static::TOGGLE_DROPDOWN; } foreach ($this->items as $key => $item) { $item = static::prepareItem($item); if ($item !== null) { $this->items[$key] = $item; } else { unset($this->items[$key]); } } BootstrapPluginAsset::register($this->getView()); }
/** * @inheritdoc */ public function init() { parent::init(); $this->options['id'] = $this->id; echo Html::beginTag('div', $this->options); if ($this->header !== null) { $this->initTools(); echo Html::beginTag('div', ['class' => 'x_title']); echo Html::tag('h2', ($this->icon !== null ? new Icon($this->icon) . ' ' : '') . $this->header); if (empty($this->tools) === false) { echo Nav::widget(['dropDownCaret' => '', 'items' => $this->tools, 'options' => ['class' => 'nav navbar-right panel_toolbox']]); } echo Html::tag('div', null, ['class' => 'clearfix']); echo Html::endTag('div'); } echo Html::beginTag('div', ['class' => 'x_content', 'style' => $this->expandable === true ? 'display: none;' : null]); }
public function run() { $languages = $this->languages; //print_pre(Yii::$app->language,'default language'); $current = $languages[Yii::$app->language]; unset($languages[Yii::$app->language]); $items = []; foreach ($languages as $code => $language) { $temp = []; $temp['label'] = $language; $temp['url'] = Url::current(['language' => $code]); array_push($items, $temp); } $this->items[] = ['label' => $current, 'items' => $items]; FlagsAsset::register($this->view); echo parent::run(); }
/** * Выполнение виджета * @return string строка, содержащая HTML виджета */ public function run() { //Заполнение заголовка if (isset($this->heading)) { $heading = '<div class="panel-heading">' . $this->heading . '</div>'; } else { $heading = ''; } //Заполнение подвала if (isset($this->footer)) { $footer = '<div class="panel-footer">' . $this->footer . '</div>'; } else { $footer = ''; } //Возврат результата return '<div class="panel ' . $this->type . '">' . $heading . '<div class="panel-body"> ' . Nav::widget(['options' => ['class' => 'nav-stacked'], 'items' => $this->items]) . ' </div>' . $footer . '</div>'; }
/** * Render the widget. */ public function run() { $menuItems = []; if (Yii::$app->user->isGuest) { $menuItems[] = ['label' => 'Регистрация', 'url' => ['/site/signup']]; $menuItems[] = ['label' => 'Войти', 'url' => ['/site/login']]; } else { $menuItems[] = ['label' => 'Счета', 'url' => ['/accounts'], 'active' => $this->controller->id === 'accounts']; $menuItems[] = ['label' => 'Операции', 'url' => ['/transaction'], 'active' => $this->controller->id === 'transaction']; $menuItems[] = ['label' => 'Цели', 'url' => ['/targets'], 'active' => $this->controller->id === 'targets']; $menuItems[] = ['label' => 'Категории', 'url' => ['/category'], 'active' => $this->controller->id === 'category']; $menuItems[] = ['label' => Yii::$app->user->identity->username, 'items' => [['label' => 'Профиль', 'url' => ['/user-panel/settings']], ['label' => 'Выход', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]; } $menus = Nav::widget(['options' => ['class' => 'nav navbar-nav navbar-right'], 'items' => $menuItems]); return $HTML = <<<HTML {$menus} HTML; }
/** * @inheritdoc */ public function init() { /** * @var Module $m */ $m = Yii::$app->getModule('user'); $currUser = Yii::$app->user; $isAdmin = $currUser->isAdmin || $currUser->isSuperuser; if ($currUser->id == $this->user) { $this->items[] = ['label' => $m->icon('eye-open') . Yii::t('user', 'View'), 'url' => [$m->actionSettings[Module::ACTION_PROFILE_INDEX]], 'active' => $this->ui === 'view', 'linkOptions' => ['title' => Yii::t('user', 'View user profile')]]; $this->items[] = ['label' => $m->icon('pencil') . Yii::t('user', 'Edit'), 'url' => [$m->actionSettings[Module::ACTION_PROFILE_UPDATE]], 'active' => $this->ui === 'edit', 'linkOptions' => ['title' => Yii::t('user', 'Edit user profile')]]; $this->items[] = ['label' => $m->icon('lock') . Yii::t('user', 'Password'), 'url' => [$m->actionSettings[Module::ACTION_ACCOUNT_PASSWORD]], 'active' => $this->ui === 'password', 'linkOptions' => ['title' => Yii::t('user', 'Change user password')]]; } elseif ($isAdmin) { $this->items[] = ['label' => $m->icon('eye-open') . Yii::t('user', 'View'), 'url' => [$m->actionSettings[Module::ACTION_PROFILE_INDEX]], 'active' => $this->ui === 'view', 'linkOptions' => ['title' => Yii::t('user', 'View user profile')]]; } if ($isAdmin) { $this->items[] = ['label' => $m->icon('wrench') . Yii::t('user', 'Manage'), 'url' => [$m->actionSettings[Module::ACTION_ADMIN_VIEW], 'id' => $this->user], 'linkOptions' => ['title' => Yii::t('user', 'Administer user profile')]]; } parent::init(); }
/** * @inheritdoc */ protected function isItemActive($item) { // Let the parent check if active. $ret = parent::isItemActive($item); // If not already active, check some other things. if (!$ret && isset($item['url'][0])) { $route = $item['url'][0]; if ($route[0] !== '/' && Yii::$app->controller) { $route = Yii::$app->controller->module->getUniqueId() . '/' . $route; } $routeTrimmed = ltrim($route, '/'); // Also check if the index route. $ret = $routeTrimmed . '/index' === $this->route; // Also check if the user profile. if (!$ret) { // XXX: Workaround for user profile not following the convention. $ret = $this->route === $routeTrimmed || strpos($this->route, $routeTrimmed . '/') !== false; } } return $ret; }