diff --git a/frontend/controllers/ArticlesController.php b/frontend/controllers/ArticlesController.php new file mode 100755 index 0000000..c6645bf --- /dev/null +++ b/frontend/controllers/ArticlesController.php @@ -0,0 +1,42 @@ +groupBy('id')->orderBy('id DESC') ; + $countQuery = clone $query; + $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize'=>18]); + $pages->forcePageParam = false; + $pages->pageSizeParam = false; + $news = $query->offset($pages->offset) + ->with(['comments.rating', 'averageRating']) + ->limit($pages->limit) + ->all(); + + return $this->render('index', [ + 'pages'=>$pages, + 'news'=>$news, + ]); + } + + public function actionShow(){ + if(!$news = Articles::find()->where(['id'=>$_GET['id']])->one()) + throw new HttpException(404, 'Данной странице не существует!'); + + return $this->render('show', [ + 'news'=>$news, + ]); + } + +} \ No newline at end of file diff --git a/frontend/views/articles/index.php b/frontend/views/articles/index.php new file mode 100755 index 0000000..5c24f5d --- /dev/null +++ b/frontend/views/articles/index.php @@ -0,0 +1,78 @@ +getModule('artbox-comment'); + CommentAsset::register($this); +?> +title = 'Блог'; + + + + $this->params['breadcrumbs'][] = $this->title; + + $this->registerMetaTag([ + 'name' => 'description', + 'content' => 'Блог', + ]); + $this->registerMetaTag([ + 'name' => 'keywords', + 'content' => 'Блог', + ]); +?> + + +
+

Блог

+ + +
+ + imageUrl, 'list'), [ 'class' => 'float-left' ]) ?> + + title ?>
+
+ averageRating && $item->averageRating->value > 0 )) { + ?> +
+ +

+ comments); + echo Html::a(( $comment_count ? 'Отзывов: ' . count($item->comments) : "Оставить отзыв" ), [ + 'articles/show', + 'translit' => $item->translit, + 'id' => $item->id, + '#' => 'artbox-comment', + ]); + ?> +

+
+ body, 600); ?> +
+
+ + +
+ $pages, + 'registerLinkTags' => true, + ]); ?> + +
diff --git a/frontend/views/articles/show.php b/frontend/views/articles/show.php new file mode 100755 index 0000000..da0d9b2 --- /dev/null +++ b/frontend/views/articles/show.php @@ -0,0 +1,56 @@ + +title = $news->meta_title; +$this->params['seo']['title'] = !empty($this->title) ?$this->title :$news->title; +$this->registerMetaTag(['name' => 'description', 'content' => $news->meta_description]); +$this->params[ 'breadcrumbs' ][] = ['label'=>'Блог','url'=>['/blog']]; +$this->params[ 'breadcrumbs' ][] = $news->title; +?> + + +
+ +
+

title?>

+
+ averageRating ) && $news->averageRating->value) { + ?> +
+ +

+ comments); + if($comment_count) { + echo "Отзывов: " . $comment_count; + } else { + echo "Оставть отзыв"; + } + ?> +

+
+ imageUrl, 'product'), ['class'=>'blog-show-img float-left'])?> + body?> +

date?>

+
+ +
+
+ $news, + 'layout' => "{form} {reply_form} {list}" + ]); + ?> +
+
+
+ +
\ No newline at end of file diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index b2b9b30..716acea 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -3,6 +3,7 @@ use common\models\Basket; use common\modules\product\models\Category; use frontend\assets\AppAsset; +use yii\bootstrap\Nav; use yii\helpers\Html; use yii\helpers\Url; use yii\widgets\Breadcrumbs; @@ -105,31 +106,29 @@ AppAsset::register($this); + 'Статьи', 'url' => '/articles/index'], + ['label' => 'Магазины', 'url' => 'site/contacts'], + ['label' => 'Скидки', 'url' => 'site/contacts'], + ['label' => 'Гарантии', 'url' => 'site/contacts'], + ['label' => 'Оплата', 'url' => 'site/contacts'], + ['label' => 'Доставка', 'url' => 'site/contacts'], + ['label' => 'Контакты', 'url' => 'site/contacts'], + ]; + + if(Yii::$app->user->isGuest){ + $items[] = ['label' => 'Личный кабинет', 'url' => '#','options' =>['data-toggle' => 'modal', 'data-target' => '#myAccount']]; + } else{ + $items[] = ['label' =>Yii::$app->user->identity->username, 'url' =>Url::toRoute(['cabinet/index'])]; + } + echo Nav::widget([ + 'options' => ['class' => 'top-menu pull-left'], + 'items' => $items + ])?> + + -
-- libgit2 0.21.4