Ejemplo n.º 1
0
 public function actionArticle()
 {
     $model = new Search();
     $articles = 1;
     if ($model->load(\Yii::$app->request->get()) && isset($model['name'])) {
         if ($model->marks != "") {
             $marks = Search::getMarksArray($model->marks);
         }
         $contentId = \Yii::$app->request->post('contentId');
         $articles = Search::searchArticles($model['name'], $model['author'], $model['id_level_1'], $model['marks'], 20, $contentId);
     }
     if (\Yii::$app->request->isAjax) {
         echo json_encode(['content' => $articles]);
         die;
     }
     $all_categories = Category::getAllTranslatedCategory();
     return $this->render('article', ['model' => $model, 'articles' => $articles, 'all_categories' => $all_categories]);
 }