コード例 #1
0
 /**
  * Finds the Menu model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Menu the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Menu::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #2
0
ファイル: MenuSearch.php プロジェクト: apuc/admin
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'descr', $this->descr]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: MenuController.php プロジェクト: apuc/admin
 public function actionSave_sort()
 {
     $arr = explode(',', $_GET['sort']);
     $i = 1;
     foreach ($arr as $a) {
         $menu = Menu::find()->where(['id' => $a])->one();
         $menu->sort = $i;
         $menu->save();
         $i++;
     }
 }
コード例 #4
0
ファイル: main.php プロジェクト: sergey-exu/kio
					<div class="col-xs-12 col-md-6">
						<div class="header-item bg-4">
							<a id="menu-open" class="" href="javascript:void(0);">Open Menu<span></span></a>

                            <?php 
if ($menuItems = \backend\modules\menu\models\Menu::find()->where(['name' => 'main'])->one()) {
    $menuItems = json_decode($menuItems['data'], true);
    echo Nav::widget(['options' => ['class' => 'header-menu mainmenu'], 'items' => $menuItems]);
} else {
    Yii::error('Не найдены настройки основного меню (mane "main")');
}
?>

							
							<?php 
if ($menuItems = \backend\modules\menu\models\Menu::find()->where(['name' => 'sub-main'])->one()) {
    $menuItems = json_decode($menuItems['data'], true);
    if (Yii::$app->user->isGuest) {
        $menuItems[] = ['label' => '<span class="glyphicon glyphicon-user" aria-hidden="true"></span> Войти', 'url' => ['/lk/login']];
    } else {
        $menuItems[] = ['label' => '<span class="glyphicon glyphicon-user" aria-hidden="true"></span> Личный кабинет', 'items' => [['label' => 'Анкета', 'url' => ['lk/data']], ['label' => 'Настройки', 'url' => ['lk/settings']], ['label' => 'Выйти', 'url' => ['lk/logout'], 'linkOptions' => ['data-method' => 'post']]]];
    }
    echo Nav::widget(['options' => ['class' => 'header-menu submenu bg-2'], 'items' => $menuItems, 'encodeLabels' => false]);
} else {
    Yii::error('Не найдены настройки дополнительного меню (mane "sub-main")');
}
?>
							
						</div>
					</div>
				</div>