Example #1
0
 public function actionArticle($category, $year, $month, $day, $id)
 {
     $item = Article::find(['id_string' => $id, 'DATE(date_insert)' => $year . $month . $day]);
     if (is_null($item)) {
         throw new Exception('Нет такой статьи');
     }
     $categoryObject = UnionCategory::find(['id_string' => $category]);
     $item->incViewCounter();
     $nearList = Article::getByTreeNodeIdQuery($categoryObject->getId())->andWhere(['not in', 'id', $item->getId()])->limit(3)->all();
     if (count($nearList) == 0) {
         $nearList = Article::query()->select('id,header,id_string,image,view_counter,description,content,date_insert')->orderBy(['date_insert' => SORT_DESC])->andWhere(['not in', 'id', $item->getId()])->limit(3)->all();
     }
     return $this->render(['item' => $item->getFields(), 'category' => $category, 'nearList' => $nearList, 'breadcrumbs' => $categoryObject->getBreadCrumbs([$item->getField('header')])]);
 }