Commit b2e6e4cc44423119e9246f2d775fe1f4b24d0f39

Authored by alex
1 parent 85f58cde

Добавил возможность создавать свои страницы в админке, + выводить их на экран

console/migrations/m180828_092957_page_update_updatedAt_createdAt.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Class m180828_092957_page_update_updatedAt_createdAt
  7 + */
  8 +class m180828_092957_page_update_updatedAt_createdAt extends Migration
  9 +{
  10 +
  11 +
  12 + // Use up()/down() to run migration code without a transaction.
  13 + public function up()
  14 + {
  15 + $this->dropColumn('page','created_at');
  16 + $this->dropColumn('page','updated_at');
  17 + $this->addColumn('page','created_at',$this->integer());
  18 + $this->addColumn('page','updated_at',$this->integer());
  19 + }
  20 +
  21 + public function down()
  22 + {
  23 +
  24 + }
  25 +
  26 +}
frontend/config/main.php
1 <?php 1 <?php
2 use artbox\core\components\SeoComponent; 2 use artbox\core\components\SeoComponent;
  3 + #use common\components\SeoComponent;
3 use frontend\components\UrlManager; 4 use frontend\components\UrlManager;
  5 + use common\models\Alias;
4 6
5 $params = array_merge( 7 $params = array_merge(
6 require( __DIR__ . '/../../common/config/params.php' ), 8 require( __DIR__ . '/../../common/config/params.php' ),
@@ -381,7 +383,9 @@ @@ -381,7 +383,9 @@
381 ], 383 ],
382 ], 384 ],
383 'seo' => [ 385 'seo' => [
384 - 'class' => SeoComponent::className(), 386 + 'class' => SeoComponent::className(),
  387 +
  388 +
385 ], 389 ],
386 'errorHandler' => [ 390 'errorHandler' => [
387 'errorAction' => 'site/error', 391 'errorAction' => 'site/error',
frontend/controllers/PageController.php 0 → 100755
  1 +<?php
  2 + namespace frontend\controllers;
  3 +
  4 + use common\components\SeoComponent;
  5 + use artbox\core\models\Page;
  6 + use yii\web\Controller;
  7 + use yii\web\NotFoundHttpException;
  8 + use Yii;
  9 +
  10 + /**
  11 + * Class PageController
  12 + *
  13 + * @package frontend\controllers
  14 + */
  15 + class PageController extends Controller
  16 + {
  17 + public function actionView($id)
  18 + {
  19 +
  20 + $model = $this->findModel($id);
  21 +
  22 + /**
  23 + * @var SeoComponent $seo
  24 + */
  25 + $seo = Yii::$app->get('seo');
  26 +
  27 + $seo->setModel($model->lang);
  28 + return $this->render(
  29 + 'view',
  30 + [
  31 + 'model' => $model,
  32 + 'images' => $model->getImages(),
  33 + ]
  34 + );
  35 + }
  36 +
  37 + protected function findModel($id)
  38 + {
  39 + /**
  40 + * @var Page $model
  41 + */
  42 + $model = Page::find()
  43 + ->where(
  44 + [
  45 + 'id' => $id,
  46 + ]
  47 + )
  48 + ->with('lang')
  49 + ->one();
  50 +
  51 + if (!empty( $model )) {
  52 +// if ($model->lang->alias_id !== Yii::$app->seo->aliasId) {
  53 +// throw new NotFoundHttpException(\Yii::t('app', 'Wrong language'));
  54 +// }
  55 + return $model;
  56 + } else {
  57 + throw new NotFoundHttpException(\Yii::t('app', 'Model not found'));
  58 + }
  59 + }
  60 + }
0 \ No newline at end of file 61 \ No newline at end of file
frontend/views/layouts/main.php
@@ -13,12 +13,16 @@ use artbox\core\models\PageCategory; @@ -13,12 +13,16 @@ use artbox\core\models\PageCategory;
13 use artbox\core\models\User; 13 use artbox\core\models\User;
14 use yii\bootstrap\Html; 14 use yii\bootstrap\Html;
15 use yii\web\View; 15 use yii\web\View;
16 - 16 +use frontend\widgets\LanguageWidget;
  17 +use common\models\Settings;
17 18
18 19
19 20
20 $seo=\Yii::$app->get('seo'); 21 $seo=\Yii::$app->get('seo');
21 \frontend\assets\AppAsset::register($this); 22 \frontend\assets\AppAsset::register($this);
  23 +
  24 +
  25 +$settings = Settings::getInstance();
22 ?> 26 ?>
23 27
24 28
@@ -56,7 +60,112 @@ j=d.createElement(s),dl=l!=&#39;dataLayer&#39;?&#39;&amp;l=&#39;+l:&#39;&#39;;j.async=true;j.src= @@ -56,7 +60,112 @@ j=d.createElement(s),dl=l!=&#39;dataLayer&#39;?&#39;&amp;l=&#39;+l:&#39;&#39;;j.async=true;j.src=
56 height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> 60 height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
57 <!-- End Google Tag Manager (noscript) --> 61 <!-- End Google Tag Manager (noscript) -->
58 <?php $this->beginBody() ?> 62 <?php $this->beginBody() ?>
  63 + <header id="header_" class="section-box-header">
  64 +
  65 + <div class="section-header">
  66 + <div class="container">
  67 + <div class="row">
  68 + <div class="col-xs-6 col-sm-1 col-md-2 logo-wr">
  69 + <a href="/">
  70 + <img src="/images/logo.png" alt="">
  71 + </a>
  72 + </div>
  73 + <div class="menu-header">
  74 + <ul>
  75 + <li><a href="#about" data-anchor="section-about-product"><?=\Yii::t('app','About Product');?></a></li>
  76 + <li><a href="#advantages" data-anchor="section-advantages"><?=\Yii::t('app','Advantages');?></a></li>
  77 + <li><a href="#trust" data-anchor="section-trusted"><?=\Yii::t('app','Believe Us');?></a></li>
  78 + <li><a href="#contacts" data-anchor="section-map"><?=\Yii::t('app','Contacts');?></a></li>
  79 + </ul>
  80 + </div>
  81 + <div class="mail-header">
  82 + <table cellpadding="0" cellspacing="0" border="0">
  83 + <tr>
  84 + <td>
  85 + <div class="sep-lang">
  86 +
  87 + <?=
  88 + LanguageWidget::widget([
  89 + 'layoutCondition' => LanguageWidget::LAYOUT_UL,
  90 + 'layoutAttributes' =>[
  91 + 'a' =>[
  92 + 'activeClass' => 'sep-lang-a'
  93 + ],
  94 + ],
  95 + ]);
  96 +
  97 + ?>
  98 +
  99 +
  100 + </div>
  101 + <a class="mail-link_"
  102 + <?=(isset($settings->email))
  103 + ?' href="mailto:'.$settings->email.'"'
  104 + :'';
  105 + ?>
  106 + >
  107 + <?=($settings->email??'')?>
  108 + </a>
  109 + </td>
  110 + </tr>
  111 + </table>
  112 +
  113 + </div>
  114 + <div class="phone-header">
  115 + <table cellpadding="0" cellspacing="0" border="0">
  116 + <tr>
  117 + <td>
  118 + <?=(isset($settings->phone))?Html::a($settings->phone,
  119 + 'tel:'.$settings->phone):'';?>
  120 + <?=(isset($settings->phone2))?Html::a($settings->phone2,
  121 + 'tel:'.$settings->phone2):'';?>
  122 + </td>
  123 + </tr>
  124 + </table>
  125 + <span class="modal-link" data-event="call" data-form="callback" ><?=\Yii::t('app','Call me!');?></span>
  126 + </div>
  127 + </div>
  128 + </div>
  129 + </div>
  130 +
  131 +
  132 + <div class="mobile-menu-hidden" style="display: none;">
  133 + <div class="close-lang-mob">
  134 + <div class="close-mobile-menu"></div>
  135 + </div>
  136 +
  137 + <div class="mobi-menu-primary">
  138 + <ul class="mobi-menu-primary-cab">
  139 + <li>
  140 + <a href="#">
  141 + <i class="icon-menu-mob icon-menu-mob-1"></i>
  142 + <p><?=\Yii::t('app','Personal office');?></p>
  143 + </a>
  144 + </li>
  145 + <li>
  146 + <a href="#">
  147 + <i class="icon-menu-mob icon-menu-mob-2"></i>
  148 + <p><?=\Yii::t('app','Preferred');?></p>
  149 + </a>
  150 + </li>
  151 +
  152 + <li class="hidden-tablet-850">
  153 + <a href="#">
  154 + <i class="icon-menu-mob icon-menu-mob-3"></i>
  155 + <p><?=\Yii::t('app','Compare');?></p>
  156 + </a>
  157 + </li>
  158 + </ul>
  159 + <ul class="mobi-menu-primary-ul">
  160 + <li><a href="/ru/site/page/kontakty"><?=\Yii::t('app','Contacts');?></a></li>
  161 + <li><a href="/ru/site/page/oplata-i-dostavka"><?=\Yii::t('app','Delivery and payment');?></a></li>
  162 + <li><a href="/ru/site/page/pomosch"><?=\Yii::t('app','Support');?></a></li>
  163 + <li><a href="/ru/brand/index" class=""><?=\Yii::t('app','Brands');?></a></li>
  164 + </ul>
  165 + </div>
  166 + </div>
59 167
  168 + </header>
60 169
61 170
62 <?= $content ?> 171 <?= $content ?>
frontend/views/page/view.php 0 → 100755
  1 +<?php
  2 + use common\components\SeoComponent;
  3 + use common\models\Image;
  4 + use common\models\Page;
  5 + use yii\web\View;
  6 + use \frontend\widgets\SideBarMenuWidget;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Page $model
  11 + * @var Page[] $pages
  12 + * @var SeoComponent $seo
  13 + * @var Image[] $images
  14 + */
  15 + $seo = \Yii::$app->get('seo');
  16 + $this->params[ 'breadcrumbs' ][] = $seo->title;
  17 +?>
  18 +<div id="content_" class="section-box-content">
  19 +
  20 + <div class="section-box-cabinet-wr">
  21 + <div class="container container-100p">
  22 + <div class="row" style="position: relative;">
  23 + <div class="hidden-xs col-sm-4 col-md-3 col-lg-3 cabinet-sidebar-wr container-padding-left-40 container-padding-right-40">
  24 + <div class="style cabinet-sidebar pages-sidebar">
  25 + <div class="style list_cab_menu_left">
  26 +
  27 +
  28 +
  29 + </div>
  30 + </div>
  31 + </div>
  32 + <div class="hidden-xs col-sm-4 col-md-3 col-lg-3"></div>
  33 + <div class="col-xs-12 col-sm-8 col-md-9 col-lg-9 cabinet-search-items-wrapp">
  34 +
  35 + <div class="style title_pages">
  36 + <?=$model->lang->title?>
  37 + </div>
  38 +
  39 + <div class=" style editor_bl">
  40 + <?=$model->lang->body?>
  41 +
  42 +
  43 + </div>
  44 + </div>
  45 + </div>
  46 + </div>
  47 + </div>
  48 +
  49 +
  50 +
  51 +
  52 +
  53 +
  54 +</div>
  55 +
frontend/views/site/index.php
@@ -30,112 +30,7 @@ $moduleRequest=\Yii::$app-&gt;getModule(&#39;request_1&#39;); @@ -30,112 +30,7 @@ $moduleRequest=\Yii::$app-&gt;getModule(&#39;request_1&#39;);
30 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCoR1Jb-mIFUjPwKiuSlmtYBEwnJOBnAgg"></script> 30 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCoR1Jb-mIFUjPwKiuSlmtYBEwnJOBnAgg"></script>
31 31
32 32
33 -<header id="header_" class="section-box-header">  
34 33
35 - <div class="section-header">  
36 - <div class="container">  
37 - <div class="row">  
38 - <div class="col-xs-6 col-sm-1 col-md-2 logo-wr">  
39 - <a href="/">  
40 - <img src="/images/logo.png" alt="">  
41 - </a>  
42 - </div>  
43 - <div class="menu-header">  
44 - <ul>  
45 - <li><a href="#about" data-anchor="section-about-product"><?=\Yii::t('app','About Product');?></a></li>  
46 - <li><a href="#advantages" data-anchor="section-advantages"><?=\Yii::t('app','Advantages');?></a></li>  
47 - <li><a href="#trust" data-anchor="section-trusted"><?=\Yii::t('app','Believe Us');?></a></li>  
48 - <li><a href="#contacts" data-anchor="section-map"><?=\Yii::t('app','Contacts');?></a></li>  
49 - </ul>  
50 - </div>  
51 - <div class="mail-header">  
52 - <table cellpadding="0" cellspacing="0" border="0">  
53 - <tr>  
54 - <td>  
55 - <div class="sep-lang">  
56 -  
57 - <?=  
58 - LanguageWidget::widget([  
59 - 'layoutCondition' => LanguageWidget::LAYOUT_UL,  
60 - 'layoutAttributes' =>[  
61 - 'a' =>[  
62 - 'activeClass' => 'sep-lang-a'  
63 - ],  
64 - ],  
65 - ]);  
66 -  
67 - ?>  
68 -  
69 -  
70 - </div>  
71 - <a class="mail-link_"  
72 - <?=(isset($settings->email))  
73 - ?' href="mailto:'.$settings->email.'"'  
74 - :'';  
75 - ?>  
76 - >  
77 - <?=($settings->email??'')?>  
78 - </a>  
79 - </td>  
80 - </tr>  
81 - </table>  
82 -  
83 - </div>  
84 - <div class="phone-header">  
85 - <table cellpadding="0" cellspacing="0" border="0">  
86 - <tr>  
87 - <td>  
88 - <?=(isset($settings->phone))?Html::a($settings->phone,  
89 - 'tel:'.$settings->phone):'';?>  
90 - <?=(isset($settings->phone2))?Html::a($settings->phone2,  
91 - 'tel:'.$settings->phone2):'';?>  
92 - </td>  
93 - </tr>  
94 - </table>  
95 - <span class="modal-link" data-event="call" data-form="callback" ><?=\Yii::t('app','Call me!');?></span>  
96 - </div>  
97 - </div>  
98 - </div>  
99 - </div>  
100 -  
101 -  
102 - <div class="mobile-menu-hidden" style="display: none;">  
103 - <div class="close-lang-mob">  
104 - <div class="close-mobile-menu"></div>  
105 - </div>  
106 -  
107 - <div class="mobi-menu-primary">  
108 - <ul class="mobi-menu-primary-cab">  
109 - <li>  
110 - <a href="#">  
111 - <i class="icon-menu-mob icon-menu-mob-1"></i>  
112 - <p><?=\Yii::t('app','Personal office');?></p>  
113 - </a>  
114 - </li>  
115 - <li>  
116 - <a href="#">  
117 - <i class="icon-menu-mob icon-menu-mob-2"></i>  
118 - <p><?=\Yii::t('app','Preferred');?></p>  
119 - </a>  
120 - </li>  
121 -  
122 - <li class="hidden-tablet-850">  
123 - <a href="#">  
124 - <i class="icon-menu-mob icon-menu-mob-3"></i>  
125 - <p><?=\Yii::t('app','Compare');?></p>  
126 - </a>  
127 - </li>  
128 - </ul>  
129 - <ul class="mobi-menu-primary-ul">  
130 - <li><a href="/ru/site/page/kontakty"><?=\Yii::t('app','Contacts');?></a></li>  
131 - <li><a href="/ru/site/page/oplata-i-dostavka"><?=\Yii::t('app','Delivery and payment');?></a></li>  
132 - <li><a href="/ru/site/page/pomosch"><?=\Yii::t('app','Support');?></a></li>  
133 - <li><a href="/ru/brand/index" class=""><?=\Yii::t('app','Brands');?></a></li>  
134 - </ul>  
135 - </div>  
136 - </div>  
137 -  
138 -</header>  
139 34
140 <!-- #content должен быть в main.php --> 35 <!-- #content должен быть в main.php -->
141 <div id="content_" class="section-box-content"> 36 <div id="content_" class="section-box-content">
frontend/web/css/change.css
@@ -37,4 +37,5 @@ input ,.form-control{ @@ -37,4 +37,5 @@ input ,.form-control{
37 } 37 }
38 .gmnoprint img { 38 .gmnoprint img {
39 max-width: none; 39 max-width: none;
40 -}  
41 \ No newline at end of file 40 \ No newline at end of file
  41 +}
  42 +