Commit d45d568200be7edd367fc2ae405c322e81453e78

Authored by Yarik
1 parent f6cc6c5f

Catalog

frontend/controllers/CategoryController.php 0 → 100755
  1 +<?php
  2 + namespace frontend\controllers;
  3 +
  4 + use artbox\catalog\models\Category;
  5 + use artbox\core\components\SeoComponent;
  6 + use artbox\core\models\Page;
  7 + use yii\data\ActiveDataProvider;
  8 + use yii\db\ActiveQuery;
  9 + use yii\web\Controller;
  10 + use yii\web\NotFoundHttpException;
  11 + use Yii;
  12 +
  13 + /**
  14 + * Class CategoryController
  15 + *
  16 + * @package frontend\controllers
  17 + */
  18 + class CategoryController extends Controller
  19 + {
  20 + /**
  21 + * Show category by ID
  22 + *
  23 + * @param int $id
  24 + *
  25 + * @param string $filter
  26 + *
  27 + * @return string
  28 + */
  29 + public function actionView($id, $filter = '')
  30 + {
  31 + $model = $this->findModel($id);
  32 + /**
  33 + * @var SeoComponent $seo
  34 + */
  35 + $seo = Yii::$app->get('seo');
  36 + $seo->setModel($model->lang);
  37 + $filterHelper = \Yii::$app->get('filter');
  38 + $filterHelper->setFilter($filter);
  39 + $query = $filterHelper->buildQuery();
  40 + $dataProvider = new ActiveDataProvider(
  41 + [
  42 + 'query' => $query,
  43 + ]
  44 + );
  45 +
  46 + return $this->render(
  47 + 'view',
  48 + [
  49 + 'model' => $model,
  50 + 'dataProvider' => $dataProvider,
  51 + ]
  52 + );
  53 + }
  54 +
  55 + /**
  56 + * Find category by ID
  57 + *
  58 + * @param $id
  59 + *
  60 + * @return \artbox\core\models\Page
  61 + * @throws \yii\web\NotFoundHttpException
  62 + */
  63 + protected function findModel($id)
  64 + {
  65 + /**
  66 + * @var SeoComponent $seo
  67 + */
  68 + $seo = Yii::$app->get('seo');
  69 + /**
  70 + * @var Page $model
  71 + */
  72 + $model = Category::findWithFilters($id)
  73 + ->with('lang')
  74 + ->with('categories.lang')
  75 + ->with(
  76 + [
  77 + 'parent' => function ($query) {
  78 + /**
  79 + * @var ActiveQuery $query
  80 + */
  81 + $query->with('lang', 'categories.lang');
  82 + },
  83 + ]
  84 + )
  85 + ->one();
  86 + if (!empty( $model )) {
  87 + if ($model->lang->alias_id !== $seo->aliasId) {
  88 + throw new NotFoundHttpException('Wrong language');
  89 + }
  90 + return $model;
  91 + } else {
  92 + throw new NotFoundHttpException('Model not found');
  93 + }
  94 + }
  95 + }
0 96 \ No newline at end of file
... ...
frontend/controllers/SiteController.php
... ... @@ -74,6 +74,18 @@
74 74 ->count();
75 75 $brandCount = Brand::find()
76 76 ->count();
  77 + $brands = Brand::find()
  78 + ->where([ 'status' => true ])
  79 + ->andWhere(
  80 + [
  81 + 'not',
  82 + [ 'image_id' => null ],
  83 + ]
  84 + )
  85 + ->orderBy([ 'sort' => SORT_ASC ])
  86 + ->limit(6)
  87 + ->with('image')
  88 + ->all();
77 89 return $this->render(
78 90 'index',
79 91 [
... ... @@ -83,6 +95,7 @@
83 95 'saleItems' => $saleItems,
84 96 'productCount' => $productCount,
85 97 'brandCount' => $brandCount,
  98 + 'brands' => $brands,
86 99 ]
87 100 );
88 101 }
... ...
frontend/views/category/view.php 0 → 100755
  1 +<?php
  2 + use artbox\catalog\helpers\FilterHelper;
  3 + use artbox\catalog\models\Brand;
  4 + use artbox\catalog\models\Category;
  5 + use artbox\catalog\models\Product;
  6 + use artbox\core\components\SeoComponent;
  7 + use yii\bootstrap\Html;
  8 + use yii\web\View;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var Category $model
  13 + * @var SeoComponent $seo
  14 + * @var FilterHelper $filterHelper
  15 + */
  16 + $seo = \Yii::$app->get('seo');
  17 + $filterHelper = \Yii::$app->get('filter');
  18 + $this->params[ 'breadcrumbs' ][] = $seo->title;
  19 +?>
  20 +<div id="content">
  21 + <div class="container">
  22 +
  23 + <div class="row">
  24 +
  25 +
  26 + <!-- *** LEFT COLUMN ***
  27 + _________________________________________________________ -->
  28 +
  29 + <div class="col-sm-3">
  30 +
  31 + <!-- *** MENUS AND FILTERS ***
  32 +_________________________________________________________ -->
  33 +
  34 + <div class="panel panel-default sidebar-menu">
  35 + <?php
  36 + if (!empty( $model->parent_id ) || !empty( $model->categories )) {
  37 + ?>
  38 + <div class="panel-body">
  39 + <ul class="nav nav-pills nav-stacked category-menu">
  40 + <li>
  41 + <?php
  42 + if (!empty( $model->parent_id )) {
  43 + echo Html::a(
  44 + $model->parent->lang->title,
  45 + [
  46 + 'view',
  47 + 'id' => $model->parent_id,
  48 + ]
  49 + );
  50 + } else {
  51 + echo Html::a($model->lang->title, '#');
  52 + }
  53 + ?>
  54 + <ul>
  55 + <?php
  56 + if (!empty( $model->parent_id )) {
  57 + foreach ($model->parent->categories as $childCategory) {
  58 + echo Html::tag(
  59 + 'li',
  60 + Html::a(
  61 + $childCategory->lang->title,
  62 + ( $childCategory->id === $model->id ) ? '#' : [
  63 + 'view',
  64 + 'id' => $childCategory->id,
  65 + ]
  66 + ),
  67 + [
  68 + 'class' => ( $childCategory->id === $model->id ) ? 'active' : '',
  69 + ]
  70 + );
  71 + }
  72 + } else {
  73 + foreach ($model->categories as $childCategory) {
  74 + echo Html::tag(
  75 + 'li',
  76 + Html::a(
  77 + $childCategory->lang->title,
  78 + [
  79 + 'view',
  80 + 'id' => $childCategory->id,
  81 + ]
  82 + )
  83 + );
  84 + }
  85 + }
  86 + ?>
  87 + </ul>
  88 + </li>
  89 + </ul>
  90 + </div>
  91 + <?php
  92 + }
  93 + ?>
  94 +
  95 + <div class="panel-heading">
  96 + <h3 class="panel-title"><?php echo \Yii::t('app', 'Бренды'); ?></h3>
  97 + </div>
  98 +
  99 + <div class="panel-body">
  100 + <div class="form-group">
  101 + <?php
  102 + foreach ($filterHelper->getBrands($model) as $brand) {
  103 + /**
  104 + * @var Product $product
  105 + * @var Brand $brand
  106 + */
  107 + echo Html::tag(
  108 + 'div',
  109 + Html::a(
  110 + $brand->lang->title,
  111 + [
  112 + '/category/view',
  113 + 'id' => $model->id,
  114 + 'filter' => $filterHelper->buildLink($brand),
  115 + ]
  116 + )
  117 + );
  118 + }
  119 + ?>
  120 + </div>
  121 + </div>
  122 + </div>
  123 +
  124 + <?php
  125 + foreach ($model->productOptionGroupCompls as $group) {
  126 + ?>
  127 + <div class="panel panel-default sidebar-menu">
  128 + <div class="panel-heading">
  129 + <h3><?php echo $group->lang->title; ?></h3>
  130 + </div>
  131 + <div class="panel-body">
  132 + <div class="form-group">
  133 + <?php
  134 + foreach ($group->options as $option) {
  135 + /**
  136 + * @var Product $product
  137 + */
  138 + echo Html::tag(
  139 + 'div',
  140 + Html::a(
  141 + $option->lang->value,
  142 + [
  143 + '/category/view',
  144 + 'id' => $model->id,
  145 + 'filter' => $filterHelper->buildLink($option),
  146 + ]
  147 + )
  148 + );
  149 + }
  150 + ?>
  151 + </div>
  152 + </div>
  153 + </div>
  154 + <?php
  155 + }
  156 + foreach ($model->productOptionGroupExcls as $group) {
  157 + ?>
  158 + <div class="panel panel-default sidebar-menu">
  159 + <div class="panel-heading">
  160 + <h3><?php echo $group->lang->title; ?></h3>
  161 + </div>
  162 + <div class="panel-body">
  163 + <div class="form-group">
  164 + <?php
  165 + foreach ($group->options as $option) {
  166 + /**
  167 + * @var Product $product
  168 + */
  169 + echo Html::tag(
  170 + 'div',
  171 + Html::a(
  172 + $option->lang->value,
  173 + [
  174 + '/category/view',
  175 + 'id' => $model->id,
  176 + 'filter' => $filterHelper->buildLink($option),
  177 + ]
  178 + )
  179 + );
  180 + }
  181 + ?>
  182 + </div>
  183 + </div>
  184 + </div>
  185 + <?php
  186 + }
  187 + foreach ($model->variantOptionGroupCompls as $group) {
  188 + ?>
  189 + <div class="panel panel-default sidebar-menu">
  190 + <div class="panel-heading">
  191 + <h3><?php echo $group->lang->title; ?></h3>
  192 + </div>
  193 + <div class="panel-body">
  194 + <div class="form-group">
  195 + <?php
  196 + foreach ($group->options as $option) {
  197 + /**
  198 + * @var Product $product
  199 + */
  200 + echo Html::tag(
  201 + 'div',
  202 + Html::a(
  203 + $option->lang->value,
  204 + [
  205 + '/category/view',
  206 + 'id' => $model->id,
  207 + 'filter' => $filterHelper->buildLink($option),
  208 + ]
  209 + )
  210 + );
  211 + }
  212 + ?>
  213 + </div>
  214 + </div>
  215 + </div>
  216 + <?php
  217 + }
  218 + foreach ($model->variantOptionGroupExcls as $group) {
  219 + ?>
  220 + <div class="panel panel-default sidebar-menu">
  221 + <div class="panel-heading">
  222 + <h3><?php echo $group->lang->title; ?></h3>
  223 + </div>
  224 + <div class="panel-body">
  225 + <div class="form-group">
  226 + <?php
  227 + foreach ($group->options as $option) {
  228 + /**
  229 + * @var Product $product
  230 + */
  231 + echo Html::tag(
  232 + 'div',
  233 + Html::a(
  234 + $option->lang->value,
  235 + [
  236 + '/category/view',
  237 + 'id' => $model->id,
  238 + 'filter' => $filterHelper->buildLink($option),
  239 + ]
  240 + )
  241 + );
  242 + }
  243 + ?>
  244 + </div>
  245 + </div>
  246 + </div>
  247 + <?php
  248 + }
  249 + ?>
  250 +
  251 + <!-- *** MENUS AND FILTERS END *** -->
  252 +
  253 + <!-- /.banner -->
  254 +
  255 + </div>
  256 + <!-- /.col-md-3 -->
  257 +
  258 + <!-- *** LEFT COLUMN END *** -->
  259 +
  260 + <!-- *** RIGHT COLUMN ***
  261 + _________________________________________________________ -->
  262 +
  263 + <div class="col-sm-9">
  264 +
  265 + <div class="row products">
  266 +
  267 + <div class="col-md-4 col-sm-6">
  268 + <div class="product">
  269 + <div class="image">
  270 + <a href="shop-product.html">
  271 + <img src="/img/product1.jpg" alt="" class="img-responsive image1">
  272 + </a>
  273 + </div>
  274 + <!-- /.image -->
  275 + <div class="text">
  276 + <h3><a href="shop-product.html">Fur coat with very but very very long name</a></h3>
  277 + <p class="price">$143.00</p>
  278 + <p class="buttons">
  279 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  280 + </p>
  281 + </div>
  282 + <!-- /.text -->
  283 + </div>
  284 + <!-- /.product -->
  285 + </div>
  286 +
  287 + <div class="col-md-4 col-sm-6">
  288 + <div class="product">
  289 + <div class="image">
  290 + <a href="shop-product.html">
  291 + <img src="/img/product2.jpg" alt="" class="img-responsive image1">
  292 + </a>
  293 + </div>
  294 + <!-- /.image -->
  295 + <div class="text">
  296 + <h3><a href="shop-product.html">White Blouse Armani</a></h3>
  297 + <p class="price">
  298 + <del>$280</del>
  299 + $143.00
  300 + </p>
  301 + <p class="buttons">
  302 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  303 + </p>
  304 + </div>
  305 + <!-- /.text -->
  306 +
  307 + <div class="ribbon sale">
  308 + <div class="theribbon">Скидки</div>
  309 + <div class="ribbon-background"></div>
  310 + </div>
  311 + <!-- /.ribbon -->
  312 +
  313 + <div class="ribbon new">
  314 + <div class="theribbon">Новое</div>
  315 + <div class="ribbon-background"></div>
  316 + </div>
  317 + <!-- /.ribbon -->
  318 + </div>
  319 + <!-- /.product -->
  320 + </div>
  321 +
  322 + <div class="col-md-4 col-sm-6">
  323 + <div class="product">
  324 + <div class="image">
  325 + <a href="shop-product.html">
  326 + <img src="/img/product3.jpg" alt="" class="img-responsive image1">
  327 + </a>
  328 + </div>
  329 + <!-- /.image -->
  330 + <div class="text">
  331 + <h3><a href="shop-product.html">Black Blouse Versace</a></h3>
  332 + <p class="price">$143.00</p>
  333 + <p class="buttons">
  334 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  335 + </p>
  336 +
  337 + </div>
  338 + <!-- /.text -->
  339 + </div>
  340 + <!-- /.product -->
  341 + </div>
  342 +
  343 + <div class="col-md-4 col-sm-6">
  344 + <div class="product">
  345 + <div class="image">
  346 + <a href="shop-product.html">
  347 + <img src="/img/product3.jpg" alt="" class="img-responsive image1">
  348 + </a>
  349 + </div>
  350 + <!-- /.image -->
  351 + <div class="text">
  352 + <h3><a href="shop-product.html">Black Blouse Versace</a></h3>
  353 + <p class="price">$143.00</p>
  354 + <p class="buttons">
  355 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  356 + </p>
  357 +
  358 + </div>
  359 + <!-- /.text -->
  360 + </div>
  361 + <!-- /.product -->
  362 + </div>
  363 +
  364 + <div class="col-md-4 col-sm-6">
  365 + <div class="product">
  366 + <div class="image">
  367 + <a href="shop-product.html">
  368 + <img src="/img/product2.jpg" alt="" class="img-responsive image1">
  369 + </a>
  370 + </div>
  371 + <!-- /.image -->
  372 + <div class="text">
  373 + <h3><a href="shop-product.html">White Blouse Versace</a></h3>
  374 + <p class="price">$143.00</p>
  375 + <p class="buttons">
  376 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  377 + </p>
  378 +
  379 + </div>
  380 +
  381 + <!-- /.text -->
  382 +
  383 + <div class="ribbon new">
  384 + <div class="theribbon">Новое</div>
  385 + <div class="ribbon-background"></div>
  386 + </div>
  387 + <!-- /.ribbon -->
  388 + </div>
  389 + <!-- /.product -->
  390 + </div>
  391 +
  392 + <div class="col-md-4 col-sm-6">
  393 + <div class="product">
  394 + <div class="image">
  395 + <a href="shop-product.html">
  396 + <img src="/img/product1.jpg" alt="" class="img-responsive image1">
  397 + </a>
  398 + </div>
  399 + <!-- /.image -->
  400 + <div class="text">
  401 + <h3><a href="shop-product.html">Fur coat</a></h3>
  402 + <p class="price">$143.00</p>
  403 + <p class="buttons">
  404 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  405 + </p>
  406 +
  407 + </div>
  408 + <!-- /.text -->
  409 + </div>
  410 + <!-- /.product -->
  411 + </div>
  412 +
  413 + <div class="col-md-4 col-sm-6">
  414 + <div class="product">
  415 + <div class="image">
  416 + <a href="shop-product.html">
  417 + <img src="/img/product1.jpg" alt="" class="img-responsive image1">
  418 + </a>
  419 + </div>
  420 + <!-- /.image -->
  421 + <div class="text">
  422 + <h3><a href="shop-product.html">Fur coat with very but very very long name</a></h3>
  423 + <p class="price">$143.00</p>
  424 + <p class="buttons">
  425 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  426 + </p>
  427 + </div>
  428 + <!-- /.text -->
  429 + </div>
  430 + <!-- /.product -->
  431 + </div>
  432 +
  433 + <div class="col-md-4 col-sm-6">
  434 + <div class="product">
  435 + <div class="image">
  436 + <a href="shop-product.html">
  437 + <img src="/img/product2.jpg" alt="" class="img-responsive image1">
  438 + </a>
  439 + </div>
  440 + <!-- /.image -->
  441 + <div class="text">
  442 + <h3><a href="shop-product.html">White Blouse Armani</a></h3>
  443 + <p class="price">
  444 + <del>$280</del>
  445 + $143.00
  446 + </p>
  447 + <p class="buttons">
  448 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  449 + </p>
  450 + </div>
  451 + <!-- /.text -->
  452 +
  453 + <div class="ribbon sale">
  454 + <div class="theribbon">Скидки</div>
  455 + <div class="ribbon-background"></div>
  456 + </div>
  457 + <!-- /.ribbon -->
  458 +
  459 + <div class="ribbon new">
  460 + <div class="theribbon">Новое</div>
  461 + <div class="ribbon-background"></div>
  462 + </div>
  463 + <!-- /.ribbon -->
  464 + </div>
  465 + <!-- /.product -->
  466 + </div>
  467 +
  468 + <div class="col-md-4 col-sm-6">
  469 + <div class="product">
  470 + <div class="image">
  471 + <a href="shop-product.html">
  472 + <img src="/img/product3.jpg" alt="" class="img-responsive image1">
  473 + </a>
  474 + </div>
  475 + <!-- /.image -->
  476 + <div class="text">
  477 + <h3><a href="shop-product.html">Black Blouse Versace</a></h3>
  478 + <p class="price">$143.00</p>
  479 + <p class="buttons">
  480 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  481 + </p>
  482 +
  483 + </div>
  484 + <!-- /.text -->
  485 + </div>
  486 + <!-- /.product -->
  487 + </div>
  488 +
  489 + <div class="col-md-4 col-sm-6">
  490 + <div class="product">
  491 + <div class="image">
  492 + <a href="shop-product.html">
  493 + <img src="/img/product3.jpg" alt="" class="img-responsive image1">
  494 + </a>
  495 + </div>
  496 + <!-- /.image -->
  497 + <div class="text">
  498 + <h3><a href="shop-product.html">Black Blouse Versace</a></h3>
  499 + <p class="price">$143.00</p>
  500 + <p class="buttons">
  501 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  502 + </p>
  503 +
  504 + </div>
  505 + <!-- /.text -->
  506 + </div>
  507 + <!-- /.product -->
  508 + </div>
  509 +
  510 + <div class="col-md-4 col-sm-6">
  511 + <div class="product">
  512 + <div class="image">
  513 + <a href="shop-product.html">
  514 + <img src="/img/product2.jpg" alt="" class="img-responsive image1">
  515 + </a>
  516 + </div>
  517 + <!-- /.image -->
  518 + <div class="text">
  519 + <h3><a href="shop-product.html">White Blouse Versace</a></h3>
  520 + <p class="price">$143.00</p>
  521 + <p class="buttons">
  522 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  523 + </p>
  524 +
  525 + </div>
  526 +
  527 + <!-- /.text -->
  528 +
  529 + <div class="ribbon new">
  530 + <div class="theribbon">Новое</div>
  531 + <div class="ribbon-background"></div>
  532 + </div>
  533 + <!-- /.ribbon -->
  534 + </div>
  535 + <!-- /.product -->
  536 + </div>
  537 +
  538 + <div class="col-md-4 col-sm-6">
  539 + <div class="product">
  540 + <div class="image">
  541 + <a href="shop-product.html">
  542 + <img src="/img/product1.jpg" alt="" class="img-responsive image1">
  543 + </a>
  544 + </div>
  545 + <!-- /.image -->
  546 + <div class="text">
  547 + <h3><a href="shop-product.html">Fur coat</a></h3>
  548 + <p class="price">$143.00</p>
  549 + <p class="buttons">
  550 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  551 + </p>
  552 +
  553 + </div>
  554 + <!-- /.text -->
  555 + </div>
  556 + <!-- /.product -->
  557 + </div>
  558 +
  559 + <div class="col-md-4 col-sm-6">
  560 + <div class="product">
  561 + <div class="image">
  562 + <a href="shop-product.html">
  563 + <img src="/img/product1.jpg" alt="" class="img-responsive image1">
  564 + </a>
  565 + </div>
  566 + <!-- /.image -->
  567 + <div class="text">
  568 + <h3><a href="shop-product.html">Fur coat with very but very very long name</a></h3>
  569 + <p class="price">$143.00</p>
  570 + <p class="buttons">
  571 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  572 + </p>
  573 + </div>
  574 + <!-- /.text -->
  575 + </div>
  576 + <!-- /.product -->
  577 + </div>
  578 +
  579 + <div class="col-md-4 col-sm-6">
  580 + <div class="product">
  581 + <div class="image">
  582 + <a href="shop-product.html">
  583 + <img src="/img/product2.jpg" alt="" class="img-responsive image1">
  584 + </a>
  585 + </div>
  586 + <!-- /.image -->
  587 + <div class="text">
  588 + <h3><a href="shop-product.html">White Blouse Armani</a></h3>
  589 + <p class="price">
  590 + <del>$280</del>
  591 + $143.00
  592 + </p>
  593 + <p class="buttons">
  594 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  595 + </p>
  596 + </div>
  597 + <!-- /.text -->
  598 +
  599 + <div class="ribbon sale">
  600 + <div class="theribbon">Скидки</div>
  601 + <div class="ribbon-background"></div>
  602 + </div>
  603 + <!-- /.ribbon -->
  604 +
  605 + <div class="ribbon new">
  606 + <div class="theribbon">Новое</div>
  607 + <div class="ribbon-background"></div>
  608 + </div>
  609 + <!-- /.ribbon -->
  610 + </div>
  611 + <!-- /.product -->
  612 + </div>
  613 +
  614 + <div class="col-md-4 col-sm-6">
  615 + <div class="product">
  616 + <div class="image">
  617 + <a href="shop-product.html">
  618 + <img src="/img/product3.jpg" alt="" class="img-responsive image1">
  619 + </a>
  620 + </div>
  621 + <!-- /.image -->
  622 + <div class="text">
  623 + <h3><a href="shop-product.html">Black Blouse Versace</a></h3>
  624 + <p class="price">$143.00</p>
  625 + <p class="buttons">
  626 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  627 + </p>
  628 +
  629 + </div>
  630 + <!-- /.text -->
  631 + </div>
  632 + <!-- /.product -->
  633 + </div>
  634 +
  635 + <div class="col-md-4 col-sm-6">
  636 + <div class="product">
  637 + <div class="image">
  638 + <a href="shop-product.html">
  639 + <img src="/img/product3.jpg" alt="" class="img-responsive image1">
  640 + </a>
  641 + </div>
  642 + <!-- /.image -->
  643 + <div class="text">
  644 + <h3><a href="shop-product.html">Black Blouse Versace</a></h3>
  645 + <p class="price">$143.00</p>
  646 + <p class="buttons">
  647 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  648 + </p>
  649 +
  650 + </div>
  651 + <!-- /.text -->
  652 + </div>
  653 + <!-- /.product -->
  654 + </div>
  655 +
  656 + <div class="col-md-4 col-sm-6">
  657 + <div class="product">
  658 + <div class="image">
  659 + <a href="shop-product.html">
  660 + <img src="/img/product2.jpg" alt="" class="img-responsive image1">
  661 + </a>
  662 + </div>
  663 + <!-- /.image -->
  664 + <div class="text">
  665 + <h3><a href="shop-product.html">White Blouse Versace</a></h3>
  666 + <p class="price">$143.00</p>
  667 + <p class="buttons">
  668 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  669 + </p>
  670 +
  671 + </div>
  672 +
  673 + <!-- /.text -->
  674 +
  675 + <div class="ribbon new">
  676 + <div class="theribbon">Новое</div>
  677 + <div class="ribbon-background"></div>
  678 + </div>
  679 + <!-- /.ribbon -->
  680 + </div>
  681 + <!-- /.product -->
  682 + </div>
  683 +
  684 + <div class="col-md-4 col-sm-6">
  685 + <div class="product">
  686 + <div class="image">
  687 + <a href="shop-product.html">
  688 + <img src="/img/product1.jpg" alt="" class="img-responsive image1">
  689 + </a>
  690 + </div>
  691 + <!-- /.image -->
  692 + <div class="text">
  693 + <h3><a href="shop-product.html">Fur coat</a></h3>
  694 + <p class="price">$143.00</p>
  695 + <p class="buttons">
  696 + <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>
  697 + </p>
  698 +
  699 + </div>
  700 + <!-- /.text -->
  701 + </div>
  702 + <!-- /.product -->
  703 + </div>
  704 + <!-- /.col-md-4 -->
  705 + </div>
  706 + <!-- /.products -->
  707 +
  708 + <div class="pages">
  709 + <!--
  710 + <p class="loadMore">
  711 + <a href="#" class="btn btn-template-main"><i class="fa fa-chevron-down"></i> Load more</a>
  712 + </p>
  713 + -->
  714 + <ul class="pagination">
  715 + <li><a href="#">&laquo;</a>
  716 + </li>
  717 + <li class="active"><a href="#">1</a>
  718 + </li>
  719 + <li><a href="#">2</a>
  720 + </li>
  721 + <li><a href="#">3</a>
  722 + </li>
  723 + <li><a href="#">4</a>
  724 + </li>
  725 + <li><a href="#">5</a>
  726 + </li>
  727 + <li><a href="#">&raquo;</a>
  728 + </li>
  729 + </ul>
  730 + </div>
  731 +
  732 +
  733 + </div>
  734 + <!-- /.col-md-9 -->
  735 +
  736 + <!-- *** RIGHT COLUMN END *** -->
  737 +
  738 + </div>
  739 +
  740 + </div>
  741 + <!-- /.container -->
  742 +</div>
  743 +<!-- /#content -->
... ...
frontend/views/layouts/_category_menu.php 0 → 100644
  1 +<?php
  2 + use artbox\catalog\models\Category;
  3 + use yii\bootstrap\Html;
  4 + use yii\web\View;
  5 +
  6 + /**
  7 + * @var View $this
  8 + * @var bool $isHome
  9 + */
  10 + $categories = Category::find()
  11 + ->with('categories.lang', 'lang')
  12 + ->where([ 'level' => 0 ])
  13 + ->all();
  14 +?>
  15 +<ul class="dropdown-menu <?php echo $isHome ? 'sidebar' : 'multi-level'; ?>" role="menu" aria-labelledby="dLabel" <?php echo $isHome ? 'id="home-category-anchor"' : ''; ?>>
  16 + <?php
  17 + foreach ($categories as $category) {
  18 + ?>
  19 + <li class="dropdown-submenu">
  20 + <?php
  21 + echo Html::a(
  22 + $category->lang->title,
  23 + [
  24 + 'category/view',
  25 + 'id' => $category->id,
  26 + ],
  27 + [
  28 + 'tabindex' => -1,
  29 + ]
  30 + );
  31 + if ( !empty( $category->categories ) ) {
  32 + ?>
  33 + <ul class="dropdown-menu">
  34 + <?php
  35 + foreach ($category->categories as $childCategory) {
  36 + echo Html::tag(
  37 + 'li',
  38 + Html::a(
  39 + $childCategory->lang->title,
  40 + [
  41 + 'category/view',
  42 + 'id' => $childCategory->id,
  43 + ]
  44 + )
  45 + );
  46 + }
  47 + }
  48 + ?>
  49 + </ul>
  50 + </li>
  51 + <?php
  52 + }
  53 + ?>
  54 +</ul>
... ...
frontend/views/layouts/main.php
... ... @@ -182,10 +182,20 @@
182 182 <div class="navbar-collapse collapse navbar-left" id="navigation">
183 183 <ul class="nav navbar-nav navbar-left">
184 184 <li class="main-nav-item active">
185   - <a href="#home-category-anchor"><span class="btn-like"><?php echo \Yii::t(
  185 + <a href="#home-category-anchor" <?php echo $isHome ? '' : 'role="button" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="200"'; ?>><span class="btn-like"><?php echo \Yii::t(
186 186 'app',
187 187 'Каталог'
188 188 ); ?><i class="fa fa-bars" aria-hidden="true"></i></span></a>
  189 + <?php
  190 + if (!$isHome) {
  191 + echo $this->render(
  192 + '_category_menu',
  193 + [
  194 + 'isHome' => $isHome,
  195 + ]
  196 + );
  197 + }
  198 + ?>
189 199 </li>
190 200 <li class="main-nav-item">
191 201 <?php
... ... @@ -382,19 +392,11 @@ _________________________________________________________ --&gt;
382 392 ?>
383 393 <div id="heading-breadcrumbs">
384 394 <div class="container">
385   - <div class="row">
386   - <div class="col-md-7">
387   - <h1><?= $seo->h1 ?></h1>
388   - </div>
389   - <div class="col-md-5">
390   - <?= Breadcrumbs::widget(
391   - [
392   - 'links' => isset( $this->params[ 'breadcrumbs' ] ) ? $this->params[ 'breadcrumbs' ] : [],
393   - ]
394   - ) ?>
395   -
396   - </div>
397   - </div>
  395 + <?= Breadcrumbs::widget(
  396 + [
  397 + 'links' => isset( $this->params[ 'breadcrumbs' ] ) ? $this->params[ 'breadcrumbs' ] : [],
  398 + ]
  399 + ) ?>
398 400 </div>
399 401 </div>
400 402 <?php
... ... @@ -411,11 +413,11 @@ _________________________________________________________ --&gt;
411 413 <div class="container">
412 414 <div class="col-md-3 col-sm-6">
413 415 <h4><?php echo \Yii::t('app', 'About us'); ?></h4>
414   -
  416 +
415 417 <p><?php echo $settings->about; ?></p>
416   -
  418 +
417 419 <hr>
418   -
  420 +
419 421 <h4>Join our monthly newsletter</h4>
420 422 <?php
421 423 $newsletterForm = ActiveForm::begin(
... ... @@ -462,7 +464,7 @@ _________________________________________________________ --&gt;
462 464 $newsletterForm::end();
463 465 ?>
464 466 <hr class="hidden-md hidden-lg hidden-sm">
465   -
  467 +
466 468 </div>
467 469 <!-- /.col-md-3 -->
468 470  
... ... @@ -474,7 +476,7 @@ _________________________________________________________ --&gt;
474 476 <div class="item same-height-row clearfix">
475 477 <div class="image same-height-always">
476 478 <a href="#">
477   - <img class="img-responsive" src="img/detailsquare.jpg" alt="">
  479 + <img class="img-responsive" src="/img/detailsquare.jpg" alt="">
478 480 </a>
479 481 </div>
480 482 <div class="name same-height-always">
... ... @@ -485,7 +487,7 @@ _________________________________________________________ --&gt;
485 487 <div class="item same-height-row clearfix">
486 488 <div class="image same-height-always">
487 489 <a href="#">
488   - <img class="img-responsive" src="img/detailsquare.jpg" alt="">
  490 + <img class="img-responsive" src="/img/detailsquare.jpg" alt="">
489 491 </a>
490 492 </div>
491 493 <div class="name same-height-always">
... ... @@ -496,7 +498,7 @@ _________________________________________________________ --&gt;
496 498 <div class="item same-height-row clearfix">
497 499 <div class="image same-height-always">
498 500 <a href="#">
499   - <img class="img-responsive" src="img/detailsquare.jpg" alt="">
  501 + <img class="img-responsive" src="/img/detailsquare.jpg" alt="">
500 502 </a>
501 503 </div>
502 504 <div class="name same-height-always">
... ... @@ -544,32 +546,32 @@ _________________________________________________________ --&gt;
544 546 <div class="photostream">
545 547 <div>
546 548 <a href="#">
547   - <img src="img/detailsquare.jpg" class="img-responsive" alt="#">
  549 + <img src="/img/detailsquare.jpg" class="img-responsive" alt="#">
548 550 </a>
549 551 </div>
550 552 <div>
551 553 <a href="#">
552   - <img src="img/detailsquare2.jpg" class="img-responsive" alt="#">
  554 + <img src="/img/detailsquare2.jpg" class="img-responsive" alt="#">
553 555 </a>
554 556 </div>
555 557 <div>
556 558 <a href="#">
557   - <img src="img/detailsquare3.jpg" class="img-responsive" alt="#">
  559 + <img src="/img/detailsquare3.jpg" class="img-responsive" alt="#">
558 560 </a>
559 561 </div>
560 562 <div>
561 563 <a href="#">
562   - <img src="img/detailsquare3.jpg" class="img-responsive" alt="#">
  564 + <img src="/img/detailsquare3.jpg" class="img-responsive" alt="#">
563 565 </a>
564 566 </div>
565 567 <div>
566 568 <a href="#">
567   - <img src="img/detailsquare2.jpg" class="img-responsive" alt="#">
  569 + <img src="/img/detailsquare2.jpg" class="img-responsive" alt="#">
568 570 </a>
569 571 </div>
570 572 <div>
571 573 <a href="#">
572   - <img src="img/detailsquare.jpg" class="img-responsive" alt="#">
  574 + <img src="/img/detailsquare.jpg" class="img-responsive" alt="#">
573 575 </a>
574 576 </div>
575 577 </div>
... ...
frontend/views/site/_slider_product.php
... ... @@ -75,7 +75,7 @@
75 75 if ($product->is(1)) {
76 76 ?>
77 77 <div class="ribbon new">
78   - <div class="theribbon">Новое</div>
  78 + <div class="theribbon"><?php echo \Yii::t('app', 'Новое'); ?></div>
79 79 <div class="ribbon-background"></div>
80 80 </div>
81 81 <?php
... ... @@ -83,7 +83,7 @@
83 83 if ($product->is(2)) {
84 84 ?>
85 85 <div class="ribbon sale">
86   - <div class="theribbon">Акция</div>
  86 + <div class="theribbon"><?php echo \Yii::t('app', 'Акция'); ?></div>
87 87 <div class="ribbon-background"></div>
88 88 </div>
89 89 <?php
... ...
frontend/views/site/index.php
1 1 <?php
  2 + use artbox\catalog\models\Brand;
2 3 use artbox\catalog\models\Category;
3 4 use artbox\catalog\models\Product;
  5 + use artbox\core\components\SeoComponent;
4 6 use yii\bootstrap\Html;
5 7 use yii\web\View;
6 8  
7 9 /**
8   - * @var View $this
9   - * @var Category[] $categories
10   - * @var Product[] $topItems
11   - * @var Product[] $newItems
12   - * @var Product[] $saleItems
13   - * @var int $brandCount
14   - * @var int $productCount
  10 + * @var View $this
  11 + * @var Category[] $categories
  12 + * @var Product[] $topItems
  13 + * @var Product[] $newItems
  14 + * @var Product[] $saleItems
  15 + * @var int $brandCount
  16 + * @var int $productCount
  17 + * @var Brand[] $brands
  18 + * @var SeoComponent $seo
15 19 */
16 20 $this->title = 'My Yii Application';
  21 + $seo = Yii::$app->get('seo');
17 22 ?>
18 23 <section class="category-carousel-box">
19 24 <!-- *** HOMEPAGE CAROUSEL ***
... ... @@ -22,46 +27,14 @@ _________________________________________________________ --&gt;
22 27  
23 28 <div class="row">
24 29 <div class="col-sm-3">
25   - <ul class="dropdown-menu sidebar" role="menu" aria-labelledby="dLabel" id="home-category-anchor">
26   - <?php
27   - foreach ($categories as $category) {
28   - ?>
29   - <li class="dropdown-submenu">
30   - <?php
31   - echo Html::a(
32   - $category->lang->title,
33   - [
34   - 'category/view',
35   - 'id' => $category->id,
36   - ],
37   - [
38   - 'tabindex' => -1,
39   - ]
40   - );
41   - if ( !empty( $category->categories ) ) {
42   - ?>
43   - <ul class="dropdown-menu">
44   - <?php
45   - foreach ($category->categories as $childCategory) {
46   - echo Html::tag(
47   - 'li',
48   - Html::a(
49   - $childCategory->lang->title,
50   - [
51   - 'category/view',
52   - 'id' => $childCategory->id,
53   - ]
54   - )
55   - );
56   - }
57   - }
58   - ?>
59   - </ul>
60   - </li>
61   - <?php
62   - }
63   - ?>
64   - </ul>
  30 + <?php
  31 + echo $this->render(
  32 + '@frontend/views/layouts/_category_menu',
  33 + [
  34 + 'isHome' => true,
  35 + ]
  36 + );
  37 + ?>
65 38 </div>
66 39  
67 40 <div class="col-sm-9">
... ... @@ -116,7 +89,7 @@ _________________________________________________________ --&gt;
116 89 <div class="heading text-center">
117 90 <h2><?php echo \Yii::t('app', 'Новинки'); ?></h2>
118 91 </div>
119   -
  92 +
120 93 <div class="product-carousel">
121 94 <div class="homepage owl-carousel">
122 95 <?php
... ... @@ -214,7 +187,7 @@ _________________________________________________________ --&gt;
214 187 <div class="icon"><i class="fa fa-cubes"></i>
215 188 </div>
216 189 <h4><span class="counter"><?php echo $productCount; ?></span><br>
217   -
  190 +
218 191 Позиций товаров</h4>
219 192 </div>
220 193 </div>
... ... @@ -223,7 +196,7 @@ _________________________________________________________ --&gt;
223 196 <div class="icon"><i class="fa fa-tags"></i>
224 197 </div>
225 198 <h4><span class="counter"><?php echo $brandCount; ?></span><br>
226   -
  199 +
227 200 Брендов</h4>
228 201 </div>
229 202 </div>
... ... @@ -232,7 +205,7 @@ _________________________________________________________ --&gt;
232 205 <div class="icon"><i class="fa fa-copy"></i>
233 206 </div>
234 207 <h4><span class="counter">12</span> ... <span class="counter">36</span><br>
235   -
  208 +
236 209 Месяцев Гарантия </h4>
237 210 </div>
238 211 </div>
... ... @@ -242,57 +215,61 @@ _________________________________________________________ --&gt;
242 215 <!-- /.container -->
243 216 </section>
244 217 <!-- /.bar -->
245   -
246   -<section class="bar background-gray no-mb">
247   - <div class="container">
248   - <div class="row">
249   - <div class="col-md-12">
250   - <div class="heading text-center">
251   - <h2>Бренды</h2>
252   - </div>
  218 +<?php
  219 + if (!empty( $brands )) {
  220 + ?>
  221 + <section class="bar background-gray no-mb">
  222 + <div class="container">
  223 + <div class="row">
  224 + <div class="col-md-12">
  225 + <div class="heading text-center">
  226 + <h2><?php echo \Yii::t('app', 'Бренды'); ?></h2>
  227 + </div>
  228 +
  229 + <ul class="owl-carousel customers">
  230 + <?php
  231 + foreach ($brands as $brand) {
  232 + echo Html::tag(
  233 + 'div',
  234 + Html::img(
  235 + $brand->image->getUrl(),
  236 + [
  237 + 'class' => 'img-responsive',
  238 + ]
  239 + ),
  240 + [
  241 + 'class' => 'item',
  242 + ]
  243 + );
  244 + }
  245 + ?>
  246 + </ul>
  247 + <!-- /.owl-carousel -->
  248 + </div>
253 249  
254   - <ul class="owl-carousel customers">
255   - <li class="item">
256   - <img src="/img/customer-1.png" alt="" class="img-responsive">
257   - </li>
258   - <li class="item">
259   - <img src="/img/customer-2.png" alt="" class="img-responsive">
260   - </li>
261   - <li class="item">
262   - <img src="/img/customer-3.png" alt="" class="img-responsive">
263   - </li>
264   - <li class="item">
265   - <img src="/img/customer-4.png" alt="" class="img-responsive">
266   - </li>
267   - <li class="item">
268   - <img src="/img/customer-5.png" alt="" class="img-responsive">
269   - </li>
270   - <li class="item">
271   - <img src="/img/customer-6.png" alt="" class="img-responsive">
272   - </li>
273   - </ul>
274   - <!-- /.owl-carousel -->
  250 + </div>
275 251 </div>
276   -
277   - </div>
278   - </div>
279   -</section>
280   -
  252 + </section>
  253 + <?php
  254 + }
  255 +?>
  256 +<?php
  257 + /* Полезные статьи
281 258 <section class="bar background-white no-mb">
282 259 <div class="container">
283   -
  260 +
284 261 <div class="col-md-12">
285 262 <div class="heading text-center">
286 263 <h2>Полезные статьи</h2>
287 264 </div>
288   -
  265 +
289 266 <p class="lead">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies
290 267 mi vitae est. Mauris placerat eleifend leo. <span class="accent">Check our blog!</span>
291 268 </p>
292   -
  269 +
293 270 <!-- *** BLOG HOMEPAGE ***
294 271 _________________________________________________________ -->
295   -
  272 +
296 273 <div class="row">
297 274 <div class="col-md-3 col-sm-6">
298 275 <div class="box-image-text blog">
... ... @@ -320,7 +297,7 @@ _________________________________________________________ --&gt;
320 297 <!-- /.box-image-text -->
321 298  
322 299 </div>
323   -
  300 +
324 301 <div class="col-md-3 col-sm-6">
325 302 <div class="box-image-text blog">
326 303 <div class="top">
... ... @@ -345,9 +322,9 @@ _________________________________________________________ --&gt;
345 322 </div>
346 323 </div>
347 324 <!-- /.box-image-text -->
348   -
  325 +
349 326 </div>
350   -
  327 +
351 328 <div class="col-md-3 col-sm-6">
352 329 <div class="box-image-text blog">
353 330 <div class="top">
... ... @@ -372,9 +349,9 @@ _________________________________________________________ --&gt;
372 349 </div>
373 350 </div>
374 351 <!-- /.box-image-text -->
375   -
  352 +
376 353 </div>
377   -
  354 +
378 355 <div class="col-md-3 col-sm-6">
379 356 <div class="box-image-text blog">
380 357 <div class="top">
... ... @@ -399,25 +376,27 @@ _________________________________________________________ --&gt;
399 376 </div>
400 377 </div>
401 378 <!-- /.box-image-text -->
402   -
  379 +
403 380 </div>
404   -
  381 +
405 382 </div>
406 383 <!-- /.row -->
407   -
  384 +
408 385 <!-- *** BLOG HOMEPAGE END *** -->
409 386  
410 387 </div>
411   -
  388 +
412 389 </div>
413 390 <!-- /.container -->
414 391 </section>
415 392 <!-- /.bar -->
  393 + */
  394 +?>
416 395  
417 396 <section class="bar background-gray no-mb">
418 397 <div class="container">
419 398 <div class="col-md-12">
420   - SEO тексты тут
  399 + <?php echo $seo->text; ?>
421 400 </div>
422 401 </div>
423 402 </section>
... ...
frontend/web/css/style.css
... ... @@ -2806,6 +2806,7 @@ p.no-margin {
2806 2806 .products {
2807 2807 content: " ";
2808 2808 display: table;
  2809 + width: 100%;
2809 2810 }
2810 2811  
2811 2812 .product {
... ...