public function actionCategory($id)
 {
     $query = News::find()->select(['news.id', 'news.title as n_title', 'news.text', 'news.date', 'categories.title as c_title'])->leftJoin('categories', 'categories.id = news.category_id')->where(['news.category_id' => $id])->orderBy('news.date DESC');
     $pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => 5]);
     $news = $query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
     return $this->render('year', ['news' => $news, 'pages' => $pages]);
 }
Example #2
0
 public function actionOneNews($id)
 {
     $onenews = News::findOne($id);
     return $this->render('one', ['onenews' => $onenews]);
 }