From b433e5606110d41ac21892eefc08c22b0e0f75fd Mon Sep 17 00:00:00 2001
From: Alex
Date: Wed, 27 Sep 2017 15:51:01 +0300
Subject: [PATCH] -Blog ready
---
frontend/controllers/BlogController.php | 4 ++++
frontend/views/blog/_article.php | 9 ++++++++-
frontend/views/blog/_sidebar.php | 91 -------------------------------------------------------------------------------------------
frontend/views/blog/article.php | 98 ++++----------------------------------------------------------------------------------------------
frontend/views/blog/index.php | 7 ++++++-
frontend/widgets/BlogSidebar.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
frontend/widgets/views/_sidebar.php | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 169 insertions(+), 187 deletions(-)
delete mode 100644 frontend/views/blog/_sidebar.php
create mode 100644 frontend/widgets/BlogSidebar.php
create mode 100644 frontend/widgets/views/_sidebar.php
diff --git a/frontend/controllers/BlogController.php b/frontend/controllers/BlogController.php
index ed433f9..2f2088b 100644
--- a/frontend/controllers/BlogController.php
+++ b/frontend/controllers/BlogController.php
@@ -70,6 +70,8 @@
];
$this->view->params[ 'breadcrumbs' ][] = $category->lang->title;
+
+ $this->view->params[ 'category' ] = $category->id;
}
$dataProvider = new ActiveDataProvider(
@@ -115,6 +117,8 @@
];
$this->view->params[ 'breadcrumbs' ][] = $tag->lang->label;
+
+ $this->view->params[ 'tag' ] = $tag->id;
}
$dataProvider = new ActiveDataProvider(
diff --git a/frontend/views/blog/_article.php b/frontend/views/blog/_article.php
index 7cb7307..e368564 100644
--- a/frontend/views/blog/_article.php
+++ b/frontend/views/blog/_article.php
@@ -53,7 +53,14 @@
'blog/article',
'alias' => $model->lang->alias,
]
- ) ?>"> 8 Comments
+ ) ?>"> getCommentsCount();
+ if ($count) {
+ echo $count;
+ } else {
+ echo '0';
+ }
+ ?> Comments
diff --git a/frontend/views/blog/_sidebar.php b/frontend/views/blog/_sidebar.php
deleted file mode 100644
index 5084ad4..0000000
--- a/frontend/views/blog/_sidebar.php
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/frontend/views/blog/article.php b/frontend/views/blog/article.php
index 14d6a97..75588e3 100644
--- a/frontend/views/blog/article.php
+++ b/frontend/views/blog/article.php
@@ -2,6 +2,7 @@
use artbox\webcomment\widgets\CommentWidget;
use artbox\weblog\models\Article;
+ use frontend\widgets\BlogSidebar;
use yii\helpers\Html;
use yii\web\View;
@@ -52,99 +53,6 @@ _________________________________________________________ -->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- = $this->render('_sidebar') ?>
+ = BlogSidebar::widget([
+ 'viewParams' => $this->params,
+ ]); ?>
diff --git a/frontend/views/blog/index.php b/frontend/views/blog/index.php
index 5b89399..62d733d 100644
--- a/frontend/views/blog/index.php
+++ b/frontend/views/blog/index.php
@@ -1,5 +1,6 @@
- = $this->render('_sidebar') ?>
+ = BlogSidebar::widget(
+ [
+ 'viewParams' => $this->params,
+ ]
+ ); ?>
diff --git a/frontend/widgets/BlogSidebar.php b/frontend/widgets/BlogSidebar.php
new file mode 100644
index 0000000..0641f35
--- /dev/null
+++ b/frontend/widgets/BlogSidebar.php
@@ -0,0 +1,48 @@
+categories = Category::find()
+ ->with('lang.alias')
+ ->all();
+
+ $this->tags = Tag::find()
+ ->with('lang.alias')
+ ->all();
+ }
+
+ public function run()
+ {
+ return $this->render(
+ '_sidebar',
+ [
+ 'categories' => $this->categories,
+ 'tags' => $this->tags,
+ 'params' => $this->viewParams,
+ ]
+ );
+ }
+ }
\ No newline at end of file
diff --git a/frontend/widgets/views/_sidebar.php b/frontend/widgets/views/_sidebar.php
new file mode 100644
index 0000000..1685a39
--- /dev/null
+++ b/frontend/widgets/views/_sidebar.php
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
libgit2 0.21.4