Commit 6c741c3cbbe7d18bab42916577e3e43cf342e2ee
1 parent
ace6c6ed
-Blog small fixes ready
Showing
3 changed files
with
38 additions
and
4 deletions
Show diff stats
models/ArticleLang.php
@@ -9,20 +9,21 @@ | @@ -9,20 +9,21 @@ | ||
9 | 9 | ||
10 | /** | 10 | /** |
11 | * This is the model class for table "blog_article_lang". | 11 | * This is the model class for table "blog_article_lang". |
12 | + | ||
12 | * | 13 | * |
13 | - * @property integer $id | 14 | +*@property integer $id |
14 | * @property integer $blog_article_id | 15 | * @property integer $blog_article_id |
15 | * @property integer $language_id | 16 | * @property integer $language_id |
16 | * @property string $title | 17 | * @property string $title |
17 | * @property string $body | 18 | * @property string $body |
18 | * @property string $body_preview | 19 | * @property string $body_preview |
19 | - * @property string $alias | ||
20 | * @property string $meta_title | 20 | * @property string $meta_title |
21 | * @property string $meta_description | 21 | * @property string $meta_description |
22 | * @property string $h1 | 22 | * @property string $h1 |
23 | * @property string $seo_text | 23 | * @property string $seo_text |
24 | * @property Article $article | 24 | * @property Article $article |
25 | * @property Language $language | 25 | * @property Language $language |
26 | + * @property Alias $alias | ||
26 | */ | 27 | */ |
27 | class ArticleLang extends ActiveRecord | 28 | class ArticleLang extends ActiveRecord |
28 | { | 29 | { |
@@ -156,6 +157,6 @@ | @@ -156,6 +157,6 @@ | ||
156 | */ | 157 | */ |
157 | public function getAlias() | 158 | public function getAlias() |
158 | { | 159 | { |
159 | - return $this->hasOne(Alias::className(), ['id' => 'alias_id']); | 160 | + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]); |
160 | } | 161 | } |
161 | } | 162 | } |
models/ArticleSearch.php
@@ -16,6 +16,8 @@ | @@ -16,6 +16,8 @@ | ||
16 | public $title; | 16 | public $title; |
17 | 17 | ||
18 | public $tag; | 18 | public $tag; |
19 | + | ||
20 | + public $category; | ||
19 | 21 | ||
20 | /** | 22 | /** |
21 | * @inheritdoc | 23 | * @inheritdoc |
@@ -40,6 +42,7 @@ | @@ -40,6 +42,7 @@ | ||
40 | [ | 42 | [ |
41 | 'title', | 43 | 'title', |
42 | 'tag', | 44 | 'tag', |
45 | + 'category', | ||
43 | ], | 46 | ], |
44 | 'string', | 47 | 'string', |
45 | ], | 48 | ], |
@@ -77,6 +80,7 @@ | @@ -77,6 +80,7 @@ | ||
77 | [ | 80 | [ |
78 | 'lang', | 81 | 'lang', |
79 | 'tags.lang', | 82 | 'tags.lang', |
83 | + 'categories.lang', | ||
80 | ] | 84 | ] |
81 | ); | 85 | ); |
82 | 86 | ||
@@ -131,6 +135,14 @@ | @@ -131,6 +135,14 @@ | ||
131 | $this->tag, | 135 | $this->tag, |
132 | ] | 136 | ] |
133 | ); | 137 | ); |
138 | + | ||
139 | + $query->andFilterWhere( | ||
140 | + [ | ||
141 | + 'ilike', | ||
142 | + 'blog_category_lang.title', | ||
143 | + $this->category, | ||
144 | + ] | ||
145 | + ); | ||
134 | 146 | ||
135 | return $dataProvider; | 147 | return $dataProvider; |
136 | } | 148 | } |
views/blog-article/index.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | use artbox\weblog\models\Article; | 3 | use artbox\weblog\models\Article; |
4 | use artbox\weblog\models\ArticleSearch; | 4 | use artbox\weblog\models\ArticleSearch; |
5 | + use artbox\weblog\models\Category; | ||
5 | use artbox\weblog\models\Tag; | 6 | use artbox\weblog\models\Tag; |
6 | use yii\data\ActiveDataProvider; | 7 | use yii\data\ActiveDataProvider; |
7 | use yii\helpers\ArrayHelper; | 8 | use yii\helpers\ArrayHelper; |
@@ -44,8 +45,28 @@ | @@ -44,8 +45,28 @@ | ||
44 | 'value' => 'lang.title', | 45 | 'value' => 'lang.title', |
45 | ], | 46 | ], |
46 | [ | 47 | [ |
48 | + 'attribute' => 'category', | ||
49 | + 'label' => \Yii::t('blog', 'Categories'), | ||
50 | + 'value' => function (Article $model) { | ||
51 | + if (empty($model->categories)) { | ||
52 | + return \Yii::$app->formatter->asText(null); | ||
53 | + } else { | ||
54 | + return implode( | ||
55 | + ',<br>', | ||
56 | + ArrayHelper::getColumn( | ||
57 | + $model->categories, | ||
58 | + function (Category $category) { | ||
59 | + return $category->lang->title; | ||
60 | + } | ||
61 | + ) | ||
62 | + ); | ||
63 | + } | ||
64 | + }, | ||
65 | + 'format' => 'html', | ||
66 | + ], | ||
67 | + [ | ||
47 | 'attribute' => 'tag', | 68 | 'attribute' => 'tag', |
48 | - 'label' => \Yii::t('catalog', 'Tags'), | 69 | + 'label' => \Yii::t('blog', 'Tags'), |
49 | 'value' => function (Article $model) { | 70 | 'value' => function (Article $model) { |
50 | if (empty($model->tags)) { | 71 | if (empty($model->tags)) { |
51 | return \Yii::$app->formatter->asText(null); | 72 | return \Yii::$app->formatter->asText(null); |