public function search($web_id) { /** @var ActiveQuery $query */ $query = MenuRecord::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]); $query->andWhere(['web_id' => $web_id]); $query->orderBy(['main' => SORT_DESC]); return $dataProvider; }
/** * Returns main menu item id for given web and language * @param $webId * @param $languageId * @return bool|string */ public static function getMainMenuItemId($webId, $languageId) { $mainMenuId = MenuRecord::find()->select('id')->where(['web_id' => $webId, 'main' => 1])->scalar(); if ($mainMenuId) { $mainMenuItemId = MenuItemRecord::find()->select('id')->where(['menu_id' => $mainMenuId, 'language_id' => $languageId, 'main' => 1])->scalar(); if ($mainMenuItemId) { return $mainMenuItemId; } } return false; }
/** * Checks if menu is mainmenu * * @param $menu_id * * @return bool */ private static function isMainMenu($menu_id) { $menuMain = MenuRecord::find()->select('main')->where(['id' => $menu_id])->scalar(); return $menuMain ? true : false; }
/** * Gets menu options for dropdown * @param $wid integer ID of web * @return string */ public function actionMenuListOptions($wid) { $items = MenuRecord::find()->where(['web_id' => $wid])->activeStatus()->orderBy('title')->all(); $itemsOptions = ['arr' => false, 'prompt' => "-- " . Yii::t('back', 'Not selected') . " --"]; return $this->renderPartial('_listOptions', compact('items', 'itemsOptions')); }