public function init() { $route = Yii::$app->controller->route; //$defaultLanguage = Lang::getDefaultLang(); $appLanguage = Yii::$app->language; //$appLanguage = $defaultLanguage->getAttribute('url'); $params = $_GET; $this->_isError = $route === Yii::$app->errorHandler->errorAction; array_unshift($params, '/' . $route); $languages = Lang::find()->all(); foreach ($languages as $language) { if ($language === $appLanguage) { continue; // Exclude the current language } $params['language'] = $language->getAttribute('url'); $this->items[] = ['label' => self::label($language->getAttribute('url')), 'url' => $params]; } parent::init(); }
public function init() { $route = Yii::$app->controller->route; $appLanguage = Yii::$app->language; $params = $_GET; $this->_isError = $route === Yii::$app->errorHandler->errorAction; array_unshift($params, '/' . $route); foreach (Yii::$app->urlManager->languages as $language) { $isWildcard = substr($language, -2) === '-*'; if ($language === $appLanguage || $isWildcard && substr($appLanguage, 0, 2) === substr($language, 0, 2)) { continue; // Exclude the current language } if ($isWildcard) { $language = substr($language, 0, 2); } $params['language'] = $language; $this->items[] = ['label' => self::label($language), 'url' => $params]; } parent::init(); }
public function init() { parent::init(); Html::removeCssClass($this->options, 'dropdown-menu'); Html::addCssClass($this->options, 'treeview-menu'); }
/** * Initializes the widget */ public function init() { parent::init(); DropdownXAsset::register($this->view); }
/** * Initializes the widget. * If you override this method, make sure you call the parent implementation first. */ public function init() { parent::init(); Html::addCssClass($this->options, 'sub-menu'); }