public function actionView() { $id = \Yii::$app->request->get('id'); $pageInfo = Pages::findOne($id); $userCount = Users::getAllCount(); return $this->render('view', ['pageInfo' => $pageInfo, 'userCount' => $userCount]); }
public function actionIndex() { $page = Pages::findOne(['slug' => Yii::$app->request->url]); $news = new ActiveDataProvider(['query' => News::find()]); if ($page == null) { return $this->render('error'); } return $this->render('index', ['page' => $page, 'news' => $news]); }
public function actionPage($slug) { $model = Pages::findOne(['slug' => $slug]); if ($model === null) { throw new NotFoundHttpException(); } // renders a view named "view" and applies a layout to it return $this->render('view', ['model' => $model]); }
public function actionPage($view) { $page = Pages::findOne(['slug' => '/' . $view]); if ($page == null) { return $this->render('error'); } $news = new ActiveDataProvider(['query' => News::find(), 'sort' => ['defaultOrder' => ['data_new' => SORT_DESC]], 'pagination' => ['pageSize' => 3, 'validatePage' => false]]); return $this->render('index', ['page' => $page, 'news' => $news]); }
public function actionIndex() { $userCount = Users::getAllCount(); $oneNewsPic = News::getOnePicIndexNewsByCategory(2); $newsA = News::getIndexNewsByCategory(2, 6); $newsB = News::getIndexNewsByCategory(5, 12); $newsC = News::getIndexNewsByCategory(7, 5); $newsF = News::getOnePicIndexNewsByCategory(2); $newsRegister = TrainUsers::getAllByCount(5); $newContent = Pages::findOne(9); if (!empty($newsRegister)) { foreach ($newsRegister as $key => $val) { $newsD[$key]['title'] = Users::getOneUserNameById($val['user_id']) . "报名" . Train::getOneTrainNameById($val['train_id']) . "已被录取"; $newsD[$key]['create_time'] = $val['create_time']; $newsD[$key]['user_id'] = $val['user_id']; } } $newsE = News::getIndexNewsByCategory(6, 5); $data = ['userCount' => $userCount, 'oneNewsPic' => $oneNewsPic, 'newsA' => $newsA, 'newsB' => $newsB, 'newsC' => $newsC, 'newsD' => $newsD, 'newsE' => $newsE, 'newsF' => $newsF, 'newsRegister' => $newContent]; return $this->render('index', ['data' => $data]); }
/** * Finds the Pages model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Pages the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Pages::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionPage() { $id = Yii::$app->request->get('id'); $model = Pages::findOne($id); }