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,7 +22,7 @@ | ||
| 22 | ->with('lang.alias') | 22 | ->with('lang.alias') |
| 23 | ->with('image') | 23 | ->with('image') |
| 24 | ->with('tags.lang.alias') | 24 | ->with('tags.lang.alias') |
| 25 | - ->with('category.lang.alias') | 25 | + ->with('categories.lang.alias') |
| 26 | ->where([ 'status' => true ]); | 26 | ->where([ 'status' => true ]); |
| 27 | 27 | ||
| 28 | $dataProvider = new ActiveDataProvider( | 28 | $dataProvider = new ActiveDataProvider( |
| @@ -54,10 +54,11 @@ | @@ -54,10 +54,11 @@ | ||
| 54 | ->with('image') | 54 | ->with('image') |
| 55 | ->with('tags.lang.alias') | 55 | ->with('tags.lang.alias') |
| 56 | ->innerJoinWith('category') | 56 | ->innerJoinWith('category') |
| 57 | - ->with('category.lang.alias') | 57 | + ->with('categories.lang.alias') |
| 58 | ->where([ 'blog_category_id' => $id ]); | 58 | ->where([ 'blog_category_id' => $id ]); |
| 59 | 59 | ||
| 60 | $category = Category::find() | 60 | $category = Category::find() |
| 61 | + ->where([ 'id' => $id ]) | ||
| 61 | ->with('lang') | 62 | ->with('lang') |
| 62 | ->one(); | 63 | ->one(); |
| 63 | 64 | ||
| @@ -99,7 +100,7 @@ | @@ -99,7 +100,7 @@ | ||
| 99 | $query = Article::find() | 100 | $query = Article::find() |
| 100 | ->with('lang.alias') | 101 | ->with('lang.alias') |
| 101 | ->with('image') | 102 | ->with('image') |
| 102 | - ->with('category.lang.alias') | 103 | + ->with('categories.lang.alias') |
| 103 | ->innerJoinWith('tags.lang.alias') | 104 | ->innerJoinWith('tags.lang.alias') |
| 104 | ->where([ 'blog_tag_id' => $id ]) | 105 | ->where([ 'blog_tag_id' => $id ]) |
| 105 | ->where([ 'blog_article.status' => true ]); | 106 | ->where([ 'blog_article.status' => true ]); |
frontend/views/blog/_article.php
| @@ -18,19 +18,19 @@ | @@ -18,19 +18,19 @@ | ||
| 18 | ) ?>"><?= $model->lang->title ?></a></h2> | 18 | ) ?>"><?= $model->lang->title ?></a></h2> |
| 19 | <div class="row"> | 19 | <div class="row"> |
| 20 | <div class="col-sm-6"> | 20 | <div class="col-sm-6"> |
| 21 | - <?php if (!empty($model->category)) { ?> | 21 | + <?php foreach ($model->categories as $category) { ?> |
| 22 | <p class="author-category"><a href="<?= Url::to( | 22 | <p class="author-category"><a href="<?= Url::to( |
| 23 | [ | 23 | [ |
| 24 | 'blog/category', | 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 | </p> | 28 | </p> |
| 29 | <?php } ?> | 29 | <?php } ?> |
| 30 | 30 | ||
| 31 | <?php if (!empty($model->tags)) { | 31 | <?php if (!empty($model->tags)) { |
| 32 | ?> | 32 | ?> |
| 33 | - <div class="post-tags"> | 33 | + <div class="post-tags"> |
| 34 | <?php | 34 | <?php |
| 35 | foreach ($model->tags as $tag) { | 35 | foreach ($model->tags as $tag) { |
| 36 | ?> | 36 | ?> |
| @@ -58,12 +58,12 @@ | @@ -58,12 +58,12 @@ | ||
| 58 | 'alias' => $model->lang->alias, | 58 | 'alias' => $model->lang->alias, |
| 59 | ] | 59 | ] |
| 60 | ) ?>"><i class="fa fa-comment-o"></i> <?php | 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 | ?> комментариев</a> | 67 | ?> комментариев</a> |
| 68 | </p> | 68 | </p> |
| 69 | </div> | 69 | </div> |
frontend/widgets/BlogSidebar.php