Commit 5842c37f104a32243d04f8d39a9dbf285d279625

Authored by Administrator
1 parent c93ce871

big commti

frontend/controllers/ArticlesController.php 0 → 100755
  1 +<?php
  2 +
  3 +namespace frontend\controllers;
  4 +
  5 +use Yii;
  6 +use yii\web\Controller;
  7 +use common\models\Articles;
  8 +use yii\web\HttpException;
  9 +use yii\data\Pagination;
  10 +
  11 +class ArticlesController extends Controller
  12 +{
  13 +
  14 + public function actionIndex()
  15 + {
  16 +
  17 + $query = Articles::find()->groupBy('id')->orderBy('id DESC') ;
  18 + $countQuery = clone $query;
  19 + $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize'=>18]);
  20 + $pages->forcePageParam = false;
  21 + $pages->pageSizeParam = false;
  22 + $news = $query->offset($pages->offset)
  23 + ->with(['comments.rating', 'averageRating'])
  24 + ->limit($pages->limit)
  25 + ->all();
  26 +
  27 + return $this->render('index', [
  28 + 'pages'=>$pages,
  29 + 'news'=>$news,
  30 + ]);
  31 + }
  32 +
  33 + public function actionShow(){
  34 + if(!$news = Articles::find()->where(['id'=>$_GET['id']])->one())
  35 + throw new HttpException(404, 'Данной странице не существует!');
  36 +
  37 + return $this->render('show', [
  38 + 'news'=>$news,
  39 + ]);
  40 + }
  41 +
  42 +}
0 43 \ No newline at end of file
... ...
frontend/views/articles/index.php 0 → 100755
  1 +<?php
  2 + use common\modules\comment\assets\CommentAsset;
  3 + use yii\helpers\Html;
  4 + use yii\helpers\Url;
  5 + use yii\widgets\Breadcrumbs;
  6 + //use app\models\News;
  7 + use yii\widgets\LinkPager;
  8 + use frontend\components\Text;
  9 + Yii::$app->getModule('artbox-comment');
  10 + CommentAsset::register($this);
  11 +?>
  12 +<?php
  13 + $this->title = 'Блог';
  14 +
  15 +
  16 +
  17 + $this->params['breadcrumbs'][] = $this->title;
  18 +
  19 + $this->registerMetaTag([
  20 + 'name' => 'description',
  21 + 'content' => 'Блог',
  22 + ]);
  23 + $this->registerMetaTag([
  24 + 'name' => 'keywords',
  25 + 'content' => 'Блог',
  26 + ]);
  27 +?>
  28 +
  29 +
  30 +<div class="container">
  31 + <h1>Блог</h1>
  32 +
  33 + <?php foreach($news as $item): ?>
  34 + <div class="news_item">
  35 + <a href="<?= Url::to([
  36 + 'articles/show',
  37 + 'translit' => $item->translit,
  38 + 'id' => $item->id,
  39 + ]) ?>">
  40 + <?= Html::img(\common\components\artboximage\ArtboxImageHelper::getImageSrc($item->imageUrl, 'list'), [ 'class' => 'float-left' ]) ?>
  41 + </a>
  42 + <a href="<?= Url::to([
  43 + 'articles/show',
  44 + 'translit' => $item->translit,
  45 + 'id' => $item->id,
  46 + ]) ?>" class="name"><?= $item->title ?></a><br/>
  47 + <div class="comment_display_block article_list_comment">
  48 + <?php
  49 + if(!empty( $item->averageRating && $item->averageRating->value > 0 )) {
  50 + ?>
  51 + <div class="rateit" data-rateit-value="<?php echo $item->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div>
  52 + <?php
  53 + }
  54 + ?>
  55 + <p>
  56 + <?php
  57 + $comment_count = count($item->comments);
  58 + echo Html::a(( $comment_count ? 'Отзывов: ' . count($item->comments) : "Оставить отзыв" ), [
  59 + 'articles/show',
  60 + 'translit' => $item->translit,
  61 + 'id' => $item->id,
  62 + '#' => 'artbox-comment',
  63 + ]);
  64 + ?>
  65 + </p>
  66 + </div>
  67 + <?= Text::getShort($item->body, 600); ?>
  68 + <div class="both"></div>
  69 + </div>
  70 + <?php endforeach; ?>
  71 +
  72 + <div class="both"></div>
  73 + <?= LinkPager::widget([
  74 + 'pagination' => $pages,
  75 + 'registerLinkTags' => true,
  76 + ]); ?>
  77 +
  78 +</div>
... ...
frontend/views/articles/show.php 0 → 100755
  1 +<?php
  2 + use common\modules\comment\widgets\CommentWidget;
  3 + use yii\helpers\Html;
  4 +use yii\widgets\Breadcrumbs;
  5 +?>
  6 +<?php
  7 +
  8 +$this->title = $news->meta_title;
  9 +$this->params['seo']['title'] = !empty($this->title) ?$this->title :$news->title;
  10 +$this->registerMetaTag(['name' => 'description', 'content' => $news->meta_description]);
  11 +$this->params[ 'breadcrumbs' ][] = ['label'=>'Блог','url'=>['/blog']];
  12 +$this->params[ 'breadcrumbs' ][] = $news->title;
  13 +?>
  14 +
  15 +
  16 +<div class="container">
  17 +
  18 + <div class="content">
  19 + <h1 class="article_title"><?=$news->title?></h1>
  20 + <div class="artbox_comment_description article_comment_description">
  21 + <?php
  22 + if(!empty( $news->averageRating ) && $news->averageRating->value) {
  23 + ?>
  24 + <div class="rateit" data-rateit-value="<?php echo $news->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div>
  25 + <?php
  26 + }
  27 + ?>
  28 + <p><a href="#artbox-comment">
  29 + <?php
  30 + $comment_count = count($news->comments);
  31 + if($comment_count) {
  32 + echo "Отзывов: " . $comment_count;
  33 + } else {
  34 + echo "Оставть отзыв";
  35 + }
  36 + ?>
  37 + </a></p>
  38 + </div>
  39 + <?= Html::img(\common\components\artboximage\ArtboxImageHelper::getImageSrc($news->imageUrl, 'product'), ['class'=>'blog-show-img float-left'])?>
  40 + <?=$news->body?>
  41 + <p class='date'><?=$news->date?></p>
  42 + </div>
  43 +
  44 + <div class="comment-wrapper" style="padding-bottom:25px">
  45 + <div class='comments-border'></div>
  46 + <?php
  47 + echo CommentWidget::widget([
  48 + 'model' => $news,
  49 + 'layout' => "{form} {reply_form} {list}"
  50 + ]);
  51 + ?>
  52 + <div class="both"></div>
  53 + </div>
  54 + <div class="both"></div>
  55 +
  56 +</div>
0 57 \ No newline at end of file
... ...
frontend/views/layouts/main.php
... ... @@ -3,6 +3,7 @@
3 3 use common\models\Basket;
4 4 use common\modules\product\models\Category;
5 5 use frontend\assets\AppAsset;
  6 +use yii\bootstrap\Nav;
6 7 use yii\helpers\Html;
7 8 use yii\helpers\Url;
8 9 use yii\widgets\Breadcrumbs;
... ... @@ -105,31 +106,29 @@ AppAsset::register($this);
105 106  
106 107  
107 108 </div>
  109 + <?php
  110 + $items = [
  111 + ['label' => 'Статьи', 'url' => '/articles/index'],
  112 + ['label' => 'Магазины', 'url' => 'site/contacts'],
  113 + ['label' => 'Скидки', 'url' => 'site/contacts'],
  114 + ['label' => 'Гарантии', 'url' => 'site/contacts'],
  115 + ['label' => 'Оплата', 'url' => 'site/contacts'],
  116 + ['label' => 'Доставка', 'url' => 'site/contacts'],
  117 + ['label' => 'Контакты', 'url' => 'site/contacts'],
  118 + ];
  119 +
  120 + if(Yii::$app->user->isGuest){
  121 + $items[] = ['label' => 'Личный кабинет', 'url' => '#','options' =>['data-toggle' => 'modal', 'data-target' => '#myAccount']];
  122 + } else{
  123 + $items[] = ['label' =>Yii::$app->user->identity->username, 'url' =>Url::toRoute(['cabinet/index'])];
  124 + }
  125 + echo Nav::widget([
  126 + 'options' => ['class' => 'top-menu pull-left'],
  127 + 'items' => $items
  128 + ])?>
  129 +
  130 +
108 131  
109   - <ul class="top-menu pull-left">
110   - <li>
111   - <a href="http://www.linija-svitla.ua/sales.htm">Распродажа</a>
112   - <ul>
113   - <li><a href="sales.htm?spec=12">Скидка -50%</a></li>
114   - <li><a href="sales.htm?spec=15">Скидка -60%</a></li>
115   - <li><a href="sales.htm?spec=2">Скидка -30%</a></li>
116   - <li><a href="sales.htm?spec=1">Скидка -40%</a></li>
117   - </ul>
118   - </li>
119   - <li><a href="http://www.linija-svitla.ua/shops.htm">Магазины</a></li>
120   - <li><a href="http://www.linija-svitla.ua/nonsimple_discounts.htm">Скидки</a></li>
121   - <li><a href="http://www.linija-svitla.ua/guarantee.htm">Гарантии</a></li>
122   - <li><a href="http://www.linija-svitla.ua/payment.htm">Оплата</a></li>
123   - <li><a href="http://www.linija-svitla.ua/delivery.htm">Доставка</a></li>
124   - <li><a href="http://www.linija-svitla.ua/contacts.htm">Контакты</a></li>
125   - <?php
126   - if (Yii::$app->user->isGuest) { ?>
127   - <li><a href="#" data-toggle="modal" data-target="#myAccount">Личный кабинет</a></li>
128   - <?php } else { ?>
129   - <li><?= Html::a( Yii::$app->user->identity->username , Url::toRoute(['cabinet/index'])); ?></li>
130   - <?php } ?>
131   -
132   - </ul>
133 132 <div id="top-cart" class="pull-right">
134 133 <button class="btn btn-cart ">Корзина <i></i></button>
135 134 <div id="top-cart-content">
... ...