Commit b224f0ae21013519b30b4207af2709198aa8cbd2

Authored by Alexey Boroda
1 parent 6fb4a732

Changes:

-Comments added (with default template)
-Discounts added
-Dynamic menu
backend/views/page/_form.php
... ... @@ -40,6 +40,10 @@ use mihaildev\elfinder\ElFinder;
40 40  
41 41 <?= $form->field($model, 'in_menu')->checkbox() ?>
42 42  
  43 + <?= $form->field($model, 'in_top_menu')->checkbox() ?>
  44 +
  45 + <?= $form->field($model, 'sort_order')->textInput() ?>
  46 +
43 47 <div class="form-group">
44 48 <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
45 49 </div>
... ...
common/models/Blog.php
... ... @@ -3,6 +3,7 @@
3 3 namespace common\models;
4 4  
5 5 use common\behaviors\SaveImgBehavior;
  6 +use common\modules\comment\models\CommentModel;
6 7 use Yii;
7 8  
8 9 /**
... ...
common/models/Comments.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use common\modules\comment\models\CommentModel;
  6 +use yii\base\Model;
  7 +
  8 +/**
  9 + * This is the model class for table "Comments".
  10 + *
  11 + */
  12 +class Comments extends Model
  13 +{
  14 + public $id;
  15 +
  16 +// public function getComments()
  17 +// {
  18 +// return CommentModel::find()
  19 +// ->where([
  20 +// 'entity_id' => 'id',
  21 +// 'artbox_comment.entity' => self::className(),
  22 +// 'artbox_comment.status' => CommentModel::STATUS_ACTIVE,
  23 +// 'artbox_comment.artbox_comment_pid' => NULL
  24 +// ]);
  25 +// }
  26 +}
... ...
common/models/Page.php
... ... @@ -14,6 +14,8 @@
14 14 * @property string $seo_text
15 15 * @property string $h1
16 16 * @property bool $in_menu
  17 + * @property bool $in_top_menu
  18 + * @property string $sort_order
17 19 */
18 20 class Page extends \yii\db\ActiveRecord
19 21 {
... ... @@ -49,6 +51,12 @@
49 51 return [
50 52 [
51 53 [
  54 + 'sort_order'
  55 + ],
  56 + 'integer'
  57 + ],
  58 + [
  59 + [
52 60 'body',
53 61 'seo_text',
54 62 ],
... ... @@ -69,6 +77,7 @@
69 77 [
70 78 [
71 79 'in_menu',
  80 + 'in_top_menu'
72 81 ],
73 82 'boolean',
74 83 ],
... ... @@ -98,7 +107,9 @@
98 107 'meta_description' => 'Meta Description',
99 108 'seo_text' => 'Seo Text',
100 109 'h1' => 'H1',
101   - 'in_menu' => 'Show in menu',
  110 + 'in_menu' => 'Show in main menu',
  111 + 'in_top_menu' => 'Show in top menu',
  112 + 'sort_order' => 'Sort order',
102 113 ];
103 114 }
104 115 }
... ...
common/modules/comment/Module.php
... ... @@ -56,7 +56,7 @@
56 56 *
57 57 * @var bool
58 58 */
59   - public static $enableRating = true;
  59 + public static $enableRating = false;
60 60  
61 61 /**
62 62 * Initializes the module.
... ...
console/migrations/m160929_141228_columns_for_page_table.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +class m160929_141228_columns_for_page_table extends Migration
  6 +{
  7 + public function up()
  8 + {
  9 + $this->addColumn('page', 'in_top_menu', $this->boolean()->defaultValue(false));
  10 + $this->addColumn('page', 'sort_order', $this->integer()->defaultValue(1));
  11 + }
  12 +
  13 + public function down()
  14 + {
  15 + $this->dropColumn('page', 'in_top_menu');
  16 + $this->dropColumn('page', 'sort_order');
  17 + }
  18 +}
... ...
frontend/config/main.php
... ... @@ -49,7 +49,6 @@ return [
49 49 'route_map' => [
50 50 'catalog' => 'catalog/category',
51 51 'product' => 'catalog/product',
52   -
53 52 ]
54 53 ],
55 54 '/' => 'site/index',
... ...
frontend/controllers/CatalogController.php
... ... @@ -155,10 +155,12 @@ class CatalogController extends \yii\web\Controller
155 155 $stockProgram = Category::find()
156 156 ->where([
157 157 'stock_program' => true,
  158 + 'parent_id' => $category->category_id,
158 159 ])->all();
159 160 $onOrder = Category::find()
160 161 ->where([
161 162 'on_order' => true,
  163 + 'parent_id' => $category->category_id,
162 164 ])->all();
163 165 return $this->render('products', [
164 166 'category' => $category,
... ...
frontend/controllers/CommentsController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace frontend\controllers;
  4 +
  5 +use yii\base\Controller;
  6 +
  7 +class CommentsController extends Controller
  8 +{
  9 + public function actionIndex()
  10 + {
  11 + return $this->render('index');
  12 + }
  13 +}
... ...
frontend/controllers/DiscountController.php 0 → 100644
  1 +<?php
  2 +namespace frontend\controllers;
  3 +
  4 +use yii\web\Controller;
  5 +use common\modules\product\models\Product;
  6 +
  7 +class DiscountController extends Controller
  8 +{
  9 + public function actionIndex()
  10 + {
  11 + $products = Product::find()
  12 + ->where([
  13 + 'akciya' => true,
  14 + ])->with('variant', 'category')
  15 + ->all();
  16 + if (!empty($products))
  17 + {
  18 + return $this->render('discount', [
  19 + 'products' => $products,
  20 + ]);
  21 + }
  22 + else
  23 + {
  24 + return $this->render('empty');
  25 + }
  26 + }
  27 +}
0 28 \ No newline at end of file
... ...
frontend/views/blog/view.php
... ... @@ -5,6 +5,8 @@
5 5 * @var View $this
6 6 */
7 7 use common\models\Blog;
  8 +use common\models\Comments;
  9 +use common\modules\comment\widgets\CommentWidget;
8 10 use yii\helpers\Url;
9 11 use yii\web\View;
10 12  
... ...
frontend/views/comments/index.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * @var Comments $comments
  4 + */
  5 +use common\models\Comments;
  6 +use common\modules\comment\widgets\CommentWidget;
  7 +
  8 +?>
  9 +
  10 +
  11 +<?php
  12 +$comments = new Comments([
  13 + 'id' => 1,
  14 +]);
  15 +echo CommentWidget::widget([
  16 + 'model' => $comments,
  17 + 'entityIdAttribute' => 'id'
  18 +]);
  19 +?>
0 20 \ No newline at end of file
... ...
frontend/views/discount/discount.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * @var Product[] $products
  4 + * @var View $this
  5 + */
  6 +use common\modules\product\models\Product;
  7 +use yii\web\View;
  8 +use common\components\artboximage\ArtboxImageHelper;
  9 +use yii\helpers\Url;
  10 +
  11 +$this->title = 'Акции';
  12 +$this->params['breadcrumbs'][] = $this->title;
  13 +
  14 +?>
  15 +
  16 +<div class="col-md-12">
  17 + <div class="title8">Акции</div>
  18 + <div class="actions_cont">
  19 + <?php
  20 + foreach ($products as $product) {
  21 + ?>
  22 + <div class="col-md-3 action">
  23 + <a href="<?php echo Url::to([
  24 + 'catalog/product',
  25 + 'product' => $product->alias,
  26 + 'variant' => $product->variant->sku,
  27 + ])?>">
  28 + <div class="picture"><?php echo ArtboxImageHelper::getImage($product->getImageUrl(), 'category_thumb'); ?></div>
  29 + <div class="a_down">
  30 + <div class="price"><?php echo $product->variant->price; ?> <span>€</span></div>
  31 + <div class="titles">
  32 + <div class="line1"><?php echo $product->name; ?></div>
  33 + <div class="line2"><?php echo $product->category->name; ?></div>
  34 + </div>
  35 + </div>
  36 + </a>
  37 + </div>
  38 + <?php } ?>
  39 + <div style="clear:both;"></div>
  40 + </div>
  41 +
  42 + <div class="down act_d">
  43 + <div class="d_title">Стильные элитные обои для вашего дома</div>
  44 + <p>Продумывая дизайн своей квартиры, мы непременно тщательно выбираем "одежду" для стен - красивые модные обои.</p>
  45 + <p class="spoiler">fdsfsdf</p>
  46 + <div class="more">
  47 + <a href="#">Узнать больше</a>
  48 + </div>
  49 + </div>
  50 +</div>
... ...
frontend/views/discount/empty.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * @var View $this
  4 + */
  5 +use yii\web\View;
  6 +
  7 +$this->title = 'Акции';
  8 +$this->params['breadcrumbs'][] = $this->title;
  9 +
  10 +echo "Товары не найдены";
0 11 \ No newline at end of file
... ...
frontend/views/layouts/main.php
... ... @@ -3,14 +3,29 @@
3 3 * @var Category[] $brands_menu
4 4 * @var \yii\web\View $this
5 5 * @var string $content
  6 + * @var Page[] $top_menu
  7 + * @var Page[] $main_menu
6 8 */
7 9  
  10 +use common\models\Page;
8 11 use common\modules\product\models\Category;
9 12 use frontend\assets\AppAsset;
10 13 use yii\helpers\Html;
11 14 use yii\helpers\Url;
12 15 use yii\widgets\Breadcrumbs;
13 16  
  17 +$top_menu = Page::find()->where([
  18 + 'in_top_menu' => true,
  19 +])->orderBy([
  20 + 'sort_order' => SORT_ASC,
  21 +])->all();
  22 +
  23 +$main_menu = Page::find()->where([
  24 + 'in_menu' => true,
  25 +])->orderBy([
  26 + 'sort_order' => SORT_ASC,
  27 +])->all();
  28 +
14 29 $this->registerMetaTag([
15 30 'name' => 'robots',
16 31 'content' => 'noindex,nofollow',
... ... @@ -39,11 +54,12 @@ $brands = Category::find()
39 54 <?php $this->beginBody(); ?>
40 55 <nav class="navbar nav1">
41 56 <ul class="nav navbar-nav">
42   - <li><a href="<?php echo Url::to(['site/page', 'id' => 2]); ?>">О нас</a></li>
43 57 <li><a href="<?php echo Url::to('/new-collections'); ?>">Новые коллекции</a></li>
44 58 <li><a href="<?php echo Url::to('/article'); ?>">События</a></li>
45 59 <li><a href="<?php echo Url::to('/blog'); ?>">Блог</a></li>
46   - <li><a href="<?php echo Url::to(['site/page', 'id' => 5]); ?>">Контакты</a></li>
  60 + <?php foreach ($top_menu as $page) { ?>
  61 + <li><a href="<?php echo Url::to(['site/page', 'id' => $page->id]); ?>"><?php echo $page->title; ?></a></li>
  62 + <?php } ?>
47 63 </ul>
48 64 </nav>
49 65 <header>
... ... @@ -74,10 +90,9 @@ $brands = Category::find()
74 90 'id' => 19,
75 91 ]); ?>">Обои</a></li>
76 92 <li><a href=" <?= Url::to(['catalog/category','category' => 'brendy-tekstilya']) ?>">Текстиль</a></li>
77   - <li><a href="<?php echo Url::to(['site/page', 'id' => 6]); ?>">Карнизы</a></li>
78   - <li><a href="<?php echo Url::to(['site/page', 'id' => 7]); ?>">Напольные покрытия</a></li>
79   - <li><a href="<?php echo Url::to(['site/page', 'id' => 8]); ?>">Contract Concept</a></li>
80   - <li><a href="<?php echo Url::to(['site/page', 'id' => 9]); ?>">Мебель</a></li>
  93 + <?php foreach ($main_menu as $page) { ?>
  94 + <li><a href="<?php echo Url::to(['site/page', 'id' => $page->id]); ?>"><?php echo $page->title; ?></a></li>
  95 + <?php } ?>
81 96 </ul>
82 97 </div>
83 98 </section>
... ...
frontend/views/site/index.php
... ... @@ -49,8 +49,8 @@ $this-&gt;title = &quot;Главная&quot;;
49 49 </section>
50 50 <section class="main-box2">
51 51 <div class="col-md-4">
52   - <div class="center_line"><a href="#" class="big_link">Акции</a></div>
53   - <div class="center_line mar13_17"><a href="#" class="but_lines">Отзывы клиентов</a></div>
  52 + <div class="center_line"><a href="<?php echo Url::to(['/discount']); ?>" class="big_link">Акции</a></div>
  53 + <div class="center_line mar13_17"><a href="<?php echo Url::to(['/comments']); ?>" class="but_lines">Отзывы клиентов</a></div>
54 54 <div class="center_line"><a href="<?php echo Url::to(['/blog']); ?>" class="big_link">Блог</a></div>
55 55 <div class="blog_block">
56 56 <a href="<?php echo Url::to([
... ...
source/actions.html 0 → 100644
  1 +<!DOCTYPE HTML>
  2 +<html lang="ru">
  3 +<head>
  4 + <meta charset="utf-8">
  5 + <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6 + <meta name="viewport" content="width=device-width, initial-scale=1">
  7 + <meta name="robots" content="noindex,nofollow">
  8 + <title>Акции</title>
  9 + <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  10 + <link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">
  11 + <link rel="stylesheet" type="text/css" href="css/fonts.css">
  12 + <link rel="stylesheet" type="text/css" href="css/style.css">
  13 +</head>
  14 +<body>
  15 + <nav class="navbar nav1">
  16 + <ul class="nav navbar-nav">
  17 + <li><a href="about.html">О нас</a></li>
  18 + <li><a href="#">Новые коллекции</a></li>
  19 + <li><a href="dates.html">События</a></li>
  20 + <li><a href="blog.html">Блог</a></li>
  21 + <li><a href="contacts.html">Контакты</a></li>
  22 + </ul>
  23 + </nav>
  24 + <header>
  25 + <div class="container">
  26 + <a href="index.html" class="main"></a>
  27 + </div>
  28 + </header>
  29 + <section class="menu">
  30 + <div class="container">
  31 + <ul>
  32 + <li class="col-md-2 col-sm-2 col-xs-12"><a href="walls.html">Обои</a></li>
  33 + <li class="col-md-2 col-sm-2 col-xs-12"><a href="textile.html">Текстиль</a></li>
  34 + <li class="col-md-2 col-sm-2 col-xs-12"><a href="eaves.html">Карнизы</a></li>
  35 + <li class="col-md-2 col-sm-2 col-xs-12"><a href="floor.html">Напольные покрытия</a></li>
  36 + <li class="col-md-2 col-sm-2 col-xs-12"><a href="contract.html">Contract Concept</a></li>
  37 + <li class="col-md-2 col-sm-2 col-xs-12"><a href="furniture.html">Мебель</a></li>
  38 + </ul>
  39 + </div>
  40 + </section>
  41 + <div class="container cont">
  42 + <div class="col-md-12">
  43 + <div class="nav_up">
  44 + <a href="index.html">Baccara Home</a> — <span>Акции</span>
  45 + </div>
  46 + <div class="col-md-12">
  47 + <div class="title8">Акции</div>
  48 + <div class="actions_cont">
  49 + <div class="col-md-3 action">
  50 + <a href="#">
  51 + <div class="picture"><img src="images/act1.png"></div>
  52 + <div class="a_down">
  53 + <div class="price">5,00 <span>€</span></div>
  54 + <div class="titles">
  55 + <div class="line1">HW</div>
  56 + <div class="line2">Gloriosus Revolution</div>
  57 + </div>
  58 + </div>
  59 + </a>
  60 + </div>
  61 + <div class="col-md-3 action">
  62 + <a href="#">
  63 + <div class="picture"><img src="images/act2.png"></div>
  64 + <div class="a_down">
  65 + <div class="price">5,00 <span>€</span></div>
  66 + <div class="titles">
  67 + <div class="line1">HW</div>
  68 + <div class="line2">Lioquid Fantasy</div>
  69 + </div>
  70 + </div>
  71 + </a>
  72 + </div>
  73 + <div class="col-md-3 action">
  74 + <a href="#">
  75 + <div class="picture"><img src="images/act3.png"></div>
  76 + <div class="a_down">
  77 + <div class="price">5,00 <span>€</span></div>
  78 + <div class="titles">
  79 + <div class="line1">Hookedonwalls</div>
  80 + <div class="line2">Jealous Walls</div>
  81 + </div>
  82 + </div>
  83 + </a>
  84 + </div>
  85 + <div class="col-md-3 action">
  86 + <a href="#">
  87 + <div class="picture"><img src="images/act4.png"></div>
  88 + <div class="a_down">
  89 + <div class="price">5,00 <span>€</span></div>
  90 + <div class="titles">
  91 + <div class="line1">Hohenberger</div>
  92 + <div class="line2">Roommate</div>
  93 + </div>
  94 + </div>
  95 + </a>
  96 + </div>
  97 + <div class="col-md-3 action">
  98 + <a href="#">
  99 + <div class="picture"><img src="images/act1.png"></div>
  100 + <div class="a_down">
  101 + <div class="price">5,00 <span>€</span></div>
  102 + <div class="titles">
  103 + <div class="line1">HW</div>
  104 + <div class="line2">Gloriosus Revolution</div>
  105 + </div>
  106 + </div>
  107 + </a>
  108 + </div>
  109 + <div class="col-md-3 action">
  110 + <a href="#">
  111 + <div class="picture"><img src="images/act2.png"></div>
  112 + <div class="a_down">
  113 + <div class="price">5,00 <span>€</span></div>
  114 + <div class="titles">
  115 + <div class="line1">HW</div>
  116 + <div class="line2">Lioquid Fantasy</div>
  117 + </div>
  118 + </div>
  119 + </a>
  120 + </div>
  121 + <div class="col-md-3 action">
  122 + <a href="#">
  123 + <div class="picture"><img src="images/act3.png"></div>
  124 + <div class="a_down">
  125 + <div class="price">5,00 <span>€</span></div>
  126 + <div class="titles">
  127 + <div class="line1">Hookedonwalls</div>
  128 + <div class="line2">Jealous Walls</div>
  129 + </div>
  130 + </div>
  131 + </a>
  132 + </div>
  133 + <div class="col-md-3 action">
  134 + <a href="#">
  135 + <div class="picture"><img src="images/act4.png"></div>
  136 + <div class="a_down">
  137 + <div class="price">5,00 <span>€</span></div>
  138 + <div class="titles">
  139 + <div class="line1">Hohenberger</div>
  140 + <div class="line2">Roommate</div>
  141 + </div>
  142 + </div>
  143 + </a>
  144 + </div>
  145 +
  146 + <div style="clear:both;"></div>
  147 + </div>
  148 +
  149 + <div class="down act_d">
  150 + <div class="d_title">Стильные элитные обои для вашего дома</div>
  151 + <p>Продумывая дизайн своей квартиры, мы непременно тщательно выбираем "одежду" для стен - красивые модные обои.</p>
  152 + <p class="spoiler">fdsfsdf</p>
  153 + <div class="more">
  154 + <a href="#">Узнать больше</a>
  155 + </div>
  156 + </div>
  157 + </div>
  158 + </div>
  159 + </div>
  160 + <footer>
  161 + <div class="container">
  162 + <div class="col-md-3 fleft">
  163 + <p>© 2006 - 2015 Шоу-рум “BACCARA HOME”</p>
  164 + </div>
  165 + <div class="col-md-3 fcenter col-xs-6">
  166 + <ul>
  167 + <li><a href="#">О нас</a></li>
  168 + <li><a href="#">Новые коллекции</a></li>
  169 + <li><a href="#">События</a></li>
  170 + <li><a href="#">Блог</a></li>
  171 + <li><a href="contacts.html">Контакты</a></li>
  172 + </ul>
  173 + </div>
  174 + <div class="col-md-3">
  175 + </div>
  176 + <div class="col-md-3 fright col-xs-6">
  177 + <div class="socbuts">
  178 + <ul>
  179 + <li><a href="https://www.facebook.com/baccaraRoom/?fref=ts" target="_blank"><img src="images/icon_fb.png"></a></li>
  180 + <li><a href="https://www.instagram.com/baccarahome/" target="_blank"><img src="images/icon_inst.png"></a></li>
  181 + <li><a href="https://www.youtube.com/channel/UCr6GslF0IhlOwr7XlLsQAbw" target="_blank"><img src="images/icon_yt.png"></a></li>
  182 + <li><a href="https://www.pinterest.com/baccarahome/?etslf=36773&eq=baccara%20home" target="_blank"><img src="images/icon_pin.png"></a></li>
  183 + </ul>
  184 + </div>
  185 + <div class="hours">Часы работы<br/>
  186 + пн–пт: 10:00 – 19:30<br/>
  187 + сб: 11:00 – 18:00</div>
  188 + </div>
  189 + </div>
  190 + </footer>
  191 + <script type="text/javascript" src="js/jquery-3.1.0.min.js"></script>
  192 + <script type="text/javascript" src="js/bootstrap.min.js"></script>
  193 + <script type="text/javascript" src="js/npm.js"></script>
  194 + <script type="text/javascript" src="js/script.js"></script>
  195 +</body>
  196 +</html>
0 197 \ No newline at end of file
... ...