From b6fc53c29f895df188445859f0ba439d68d213a6 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 10 May 2017 17:36:57 +0300 Subject: [PATCH] -Blog ready --- frontend/controllers/BlogController.php | 29 ++++++++++++++++++----------- frontend/views/blog/category.php | 23 +++-------------------- frontend/views/blog/index.php | 23 +++-------------------- frontend/views/blog/tag.php | 23 +++-------------------- frontend/views/blog/view.php | 23 +++-------------------- frontend/widgets/BlogSearch.php | 18 ++++++++++++++++++ frontend/widgets/views/_blog_search.php | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 81 insertions(+), 91 deletions(-) create mode 100644 frontend/widgets/BlogSearch.php create mode 100644 frontend/widgets/views/_blog_search.php diff --git a/frontend/controllers/BlogController.php b/frontend/controllers/BlogController.php index 8cd6162..c29d635 100644 --- a/frontend/controllers/BlogController.php +++ b/frontend/controllers/BlogController.php @@ -16,7 +16,7 @@ */ class BlogController extends Controller { - public function actionIndex() + public function actionIndex($q = '') { $tags = Tag::find() ->with( @@ -33,11 +33,18 @@ 'created_at' => SORT_DESC, ] ) - ->with( + ->joinWith( [ 'lang', 'categories.lang', ] + ) + ->andFilterWhere( + [ + 'like', + 'blog_article_lang.title', + $q, + ] ), 'pagination' => [ 'pageSize' => 3, @@ -57,11 +64,11 @@ public function actionArticle($id) { $model = $this->findModel($id); - + $tags = Tag::find() ->with([ 'lang' ]) ->all(); - + return $this->render( 'view', [ @@ -80,7 +87,7 @@ ] ) ->all(); - + /** * @var Category $model */ @@ -96,7 +103,7 @@ ] ) ->one(); - + $dataProvider = new ActiveDataProvider( [ 'query' => $model->getArticles() @@ -116,7 +123,7 @@ ], ] ); - + return $this->render( 'category', [ @@ -136,7 +143,7 @@ ] ) ->all(); - + /** * @var Category $model */ @@ -152,7 +159,7 @@ ] ) ->one(); - + $dataProvider = new ActiveDataProvider( [ 'query' => $model->getArticles() @@ -172,7 +179,7 @@ ], ] ); - + return $this->render( 'tag', [ @@ -204,7 +211,7 @@ ] ) ->one(); - + if (empty($model)) { throw new NotFoundHttpException(\Yii::t('app', 'Article not found')); } else { diff --git a/frontend/views/blog/category.php b/frontend/views/blog/category.php index 497467c..136a48c 100644 --- a/frontend/views/blog/category.php +++ b/frontend/views/blog/category.php @@ -3,6 +3,7 @@ use artbox\core\components\SeoComponent; use artbox\weblog\models\Category; use artbox\weblog\models\Tag; + use frontend\widgets\BlogSearch; use yii\data\ActiveDataProvider; use yii\helpers\Url; use yii\web\View; @@ -78,26 +79,8 @@ _________________________________________________________ --> - - + + - - + + - - + + - - + +