Commit 9f58b40cbd55e3de63778e32e252f8c45ca72e71
1 parent
5b19bab7
-Blog category fixed
Showing
3 changed files
with
15 additions
and
13 deletions
Show diff stats
frontend/controllers/BlogController.php
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | ->with('lang.alias') |
| 23 | 23 | ->with('image') |
| 24 | 24 | ->with('tags.lang.alias') |
| 25 | - ->with('category.lang.alias') | |
| 25 | + ->with('categories.lang.alias') | |
| 26 | 26 | ->where([ 'status' => true ]); |
| 27 | 27 | |
| 28 | 28 | $dataProvider = new ActiveDataProvider( |
| ... | ... | @@ -54,10 +54,11 @@ |
| 54 | 54 | ->with('image') |
| 55 | 55 | ->with('tags.lang.alias') |
| 56 | 56 | ->innerJoinWith('category') |
| 57 | - ->with('category.lang.alias') | |
| 57 | + ->with('categories.lang.alias') | |
| 58 | 58 | ->where([ 'blog_category_id' => $id ]); |
| 59 | 59 | |
| 60 | 60 | $category = Category::find() |
| 61 | + ->where([ 'id' => $id ]) | |
| 61 | 62 | ->with('lang') |
| 62 | 63 | ->one(); |
| 63 | 64 | |
| ... | ... | @@ -99,7 +100,7 @@ |
| 99 | 100 | $query = Article::find() |
| 100 | 101 | ->with('lang.alias') |
| 101 | 102 | ->with('image') |
| 102 | - ->with('category.lang.alias') | |
| 103 | + ->with('categories.lang.alias') | |
| 103 | 104 | ->innerJoinWith('tags.lang.alias') |
| 104 | 105 | ->where([ 'blog_tag_id' => $id ]) |
| 105 | 106 | ->where([ 'blog_article.status' => true ]); | ... | ... |
frontend/views/blog/_article.php
| ... | ... | @@ -18,19 +18,19 @@ |
| 18 | 18 | ) ?>"><?= $model->lang->title ?></a></h2> |
| 19 | 19 | <div class="row"> |
| 20 | 20 | <div class="col-sm-6"> |
| 21 | - <?php if (!empty($model->category)) { ?> | |
| 21 | + <?php foreach ($model->categories as $category) { ?> | |
| 22 | 22 | <p class="author-category"><a href="<?= Url::to( |
| 23 | 23 | [ |
| 24 | 24 | 'blog/category', |
| 25 | - 'alias' => $model->category->lang->alias, | |
| 25 | + 'alias' => $category->lang->alias, | |
| 26 | 26 | ] |
| 27 | - ) ?>"><?= $model->category->lang->title ?></a> | |
| 27 | + ) ?>"><?= $category->lang->title ?></a> | |
| 28 | 28 | </p> |
| 29 | 29 | <?php } ?> |
| 30 | 30 | |
| 31 | 31 | <?php if (!empty($model->tags)) { |
| 32 | 32 | ?> |
| 33 | - <div class="post-tags"> | |
| 33 | + <div class="post-tags"> | |
| 34 | 34 | <?php |
| 35 | 35 | foreach ($model->tags as $tag) { |
| 36 | 36 | ?> |
| ... | ... | @@ -58,12 +58,12 @@ |
| 58 | 58 | 'alias' => $model->lang->alias, |
| 59 | 59 | ] |
| 60 | 60 | ) ?>"><i class="fa fa-comment-o"></i> <?php |
| 61 | - $count = $model->getCommentsCount(); | |
| 62 | - if ($count) { | |
| 63 | - echo $count; | |
| 64 | - } else { | |
| 65 | - echo '0'; | |
| 66 | - } | |
| 61 | + $count = $model->getCommentsCount(); | |
| 62 | + if ($count) { | |
| 63 | + echo $count; | |
| 64 | + } else { | |
| 65 | + echo '0'; | |
| 66 | + } | |
| 67 | 67 | ?> комментариев</a> |
| 68 | 68 | </p> |
| 69 | 69 | </div> | ... | ... |