Example #1
0
 public function actionNavbar()
 {
     //读出一级菜单,以便在增加二级菜单找到所属
     $nav = AgMnav::find()->where(['status' => 1])->all();
     $navbar = AgMnavbar::find()->with('mnav');
     //分页数据
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $navbar->count()]);
     $navbar = $navbar->orderBy('pid ASC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('navbar', ['nav' => $nav, 'navbar' => $navbar, 'pagination' => $pagination]);
 }
Example #2
0
 /**
  * 关联一级导航
  */
 public function getMnav()
 {
     return $this->hasOne(AgMnav::className(), ['id' => 'pid']);
 }
Example #3
0
 public function run()
 {
     $nav = AgMnav::find()->with('mbar')->where(['status' => 1])->orderBy('id asc')->all();
     return $this->render('@app/views/site/_nav', ["nav" => $nav]);
 }