Commit 1ec3afef6710320492cbb9e9e37121576509ea85
1 parent
70eb26db
VItaliy 27.11.2015
Showing
24 changed files
with
172 additions
and
80 deletions
Show diff stats
.htaccess
backend/components/views/image_sizer.php
@@ -90,8 +90,7 @@ $this->registerCssFile('@web/js/vendor/bower/jquery-file-upload/css/jquery.fileu | @@ -90,8 +90,7 @@ $this->registerCssFile('@web/js/vendor/bower/jquery-file-upload/css/jquery.fileu | ||
90 | 90 | ||
91 | <?= Html::activeHiddenInput( $model,$field,['id' => "{$field}_picture_link"]) ?> | 91 | <?= Html::activeHiddenInput( $model,$field,['id' => "{$field}_picture_link"]) ?> |
92 | 92 | ||
93 | - <input type="hidden" name="ImageSizerForm[width]" value="<?=$width?>"/> | ||
94 | - <input type="hidden" name="ImageSizerForm[height]" value="<?=$height?>"/> | 93 | + |
95 | <input type="hidden" name="ImageSizerForm[multi]" value="<?=$multi?>"/> | 94 | <input type="hidden" name="ImageSizerForm[multi]" value="<?=$multi?>"/> |
96 | 95 | ||
97 | <div id="<?= $field?>_img_block"> | 96 | <div id="<?= $field?>_img_block"> |
@@ -107,6 +106,7 @@ $this->registerCssFile('@web/js/vendor/bower/jquery-file-upload/css/jquery.fileu | @@ -107,6 +106,7 @@ $this->registerCssFile('@web/js/vendor/bower/jquery-file-upload/css/jquery.fileu | ||
107 | 106 | ||
108 | $("#<?= $field?>").fileupload({ | 107 | $("#<?= $field?>").fileupload({ |
109 | dataType: 'json', | 108 | dataType: 'json', |
109 | + formData: {width: <?=$width?>,height:<?=$height?>}, | ||
110 | done: function (e, data) { | 110 | done: function (e, data) { |
111 | 111 | ||
112 | var img = data.result.view; | 112 | var img = data.result.view; |
backend/controllers/EmailsController.php
@@ -15,6 +15,10 @@ use yii\filters\AccessControl; | @@ -15,6 +15,10 @@ use yii\filters\AccessControl; | ||
15 | */ | 15 | */ |
16 | class EmailsController extends Controller | 16 | class EmailsController extends Controller |
17 | { | 17 | { |
18 | + | ||
19 | + | ||
20 | + public $layout = "/column"; | ||
21 | + | ||
18 | /** | 22 | /** |
19 | * @inheritdoc | 23 | * @inheritdoc |
20 | */ | 24 | */ |
backend/controllers/NewsController.php
@@ -107,6 +107,16 @@ class NewsController extends BaseController | @@ -107,6 +107,16 @@ class NewsController extends BaseController | ||
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | + | ||
111 | + if(isset($model['price_list']) && !empty($model['price_list'])){ | ||
112 | + $price_list ='<div> | ||
113 | + <img src="http://'.$_SERVER['SERVER_NAME'].'/images/ico_exel.png"> | ||
114 | + <a href="'.'http://'.$_SERVER['SERVER_NAME'].$model['price_list'].'">Скачать список товаров</a> | ||
115 | + </div>'; | ||
116 | + }else { | ||
117 | + $price_list = ''; | ||
118 | + } | ||
119 | + | ||
110 | if (count($sEmails)>0) { | 120 | if (count($sEmails)>0) { |
111 | $fp = fopen('logs.txt', 'w'); | 121 | $fp = fopen('logs.txt', 'w'); |
112 | foreach ($sEmails as $mailing) { | 122 | foreach ($sEmails as $mailing) { |
@@ -116,7 +126,7 @@ class NewsController extends BaseController | @@ -116,7 +126,7 @@ class NewsController extends BaseController | ||
116 | $deny = $this->deny($deny_data); | 126 | $deny = $this->deny($deny_data); |
117 | unset($deny_data); | 127 | unset($deny_data); |
118 | 128 | ||
119 | - $data['data'] = $model['content']."<br><br>".$deny; | 129 | + $data['data'] = $model['content']."<br>".$price_list."<br>".$deny; |
120 | Emails::get('news',$data,$mailing); | 130 | Emails::get('news',$data,$mailing); |
121 | fwrite($fp, $mailing); | 131 | fwrite($fp, $mailing); |
122 | 132 |
backend/controllers/PageController.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | namespace backend\controllers; | 3 | namespace backend\controllers; |
4 | 4 | ||
5 | +use backend\components\base\BaseController; | ||
5 | use Yii; | 6 | use Yii; |
6 | use common\models\Page; | 7 | use common\models\Page; |
7 | use common\models\PageSearch; | 8 | use common\models\PageSearch; |
@@ -13,8 +14,12 @@ use yii\filters\AccessControl; | @@ -13,8 +14,12 @@ use yii\filters\AccessControl; | ||
13 | /** | 14 | /** |
14 | * PageController implements the CRUD actions for Page model. | 15 | * PageController implements the CRUD actions for Page model. |
15 | */ | 16 | */ |
16 | -class PageController extends Controller | 17 | +class PageController extends BaseController |
17 | { | 18 | { |
19 | + | ||
20 | + | ||
21 | + public $layout = "/column"; | ||
22 | + | ||
18 | /** | 23 | /** |
19 | * @inheritdoc | 24 | * @inheritdoc |
20 | */ | 25 | */ |
backend/controllers/PartnersController.php
@@ -15,6 +15,7 @@ use yii\filters\AccessControl; | @@ -15,6 +15,7 @@ use yii\filters\AccessControl; | ||
15 | */ | 15 | */ |
16 | class PartnersController extends Controller | 16 | class PartnersController extends Controller |
17 | { | 17 | { |
18 | + public $layout = "/column"; | ||
18 | /** | 19 | /** |
19 | * @inheritdoc | 20 | * @inheritdoc |
20 | */ | 21 | */ |
backend/controllers/SliderController.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | namespace backend\controllers; | 3 | namespace backend\controllers; |
4 | 4 | ||
5 | +use backend\components\base\BaseController; | ||
5 | use Yii; | 6 | use Yii; |
6 | use common\models\Slider; | 7 | use common\models\Slider; |
7 | use common\models\SliderSearch; | 8 | use common\models\SliderSearch; |
@@ -13,8 +14,10 @@ use yii\filters\AccessControl; | @@ -13,8 +14,10 @@ use yii\filters\AccessControl; | ||
13 | /** | 14 | /** |
14 | * SliderController implements the CRUD actions for Slider model. | 15 | * SliderController implements the CRUD actions for Slider model. |
15 | */ | 16 | */ |
16 | -class SliderController extends Controller | 17 | +class SliderController extends BaseController |
17 | { | 18 | { |
19 | + | ||
20 | + public $layout = "/column"; | ||
18 | /** | 21 | /** |
19 | * @inheritdoc | 22 | * @inheritdoc |
20 | */ | 23 | */ |
backend/views/layouts/column.php
@@ -342,7 +342,6 @@ $this->beginContent('@app/views/layouts/main.php'); | @@ -342,7 +342,6 @@ $this->beginContent('@app/views/layouts/main.php'); | ||
342 | ['label' => 'Текстовые страницы', 'url' => ['page/index']], | 342 | ['label' => 'Текстовые страницы', 'url' => ['page/index']], |
343 | ['label' => 'Новости', 'url' => ['news/index']], | 343 | ['label' => 'Новости', 'url' => ['news/index']], |
344 | ['label' => 'Слайдер', 'url' => ['slider/index']], | 344 | ['label' => 'Слайдер', 'url' => ['slider/index']], |
345 | - ['label' => 'Партнёры', 'url' => ['partners/index']], | ||
346 | ], | 345 | ], |
347 | ], | 346 | ], |
348 | ['label' => 'Платежные системы', 'options'=>['class'=>'label_9'], 'url' => ['#'], 'items' => [ | 347 | ['label' => 'Платежные системы', 'options'=>['class'=>'label_9'], 'url' => ['#'], 'items' => [ |
backend/views/news/index.php
@@ -34,11 +34,29 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -34,11 +34,29 @@ $this->params['breadcrumbs'][] = $this->title; | ||
34 | //'title', | 34 | //'title', |
35 | //'kwords', | 35 | //'kwords', |
36 | //'descr', | 36 | //'descr', |
37 | - | ||
38 | - 'is_active', | 37 | + [ |
38 | + 'format' => 'raw', | ||
39 | + 'filter' => [ | ||
40 | + '1'=>'Отображаются', | ||
41 | + '0'=>'Скрытые', | ||
42 | + ], | ||
43 | + 'value' => function($data){ | ||
44 | + if($data->is_active){ | ||
45 | + $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>'; | ||
46 | + } else { | ||
47 | + $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>'; | ||
48 | + } | ||
49 | + return $status_img; | ||
50 | + }, | ||
51 | + 'attribute'=>'is_active', | ||
52 | + ], | ||
39 | //'mail_send', | 53 | //'mail_send', |
40 | 'mails_count', | 54 | 'mails_count', |
41 | [ | 55 | [ |
56 | + 'format' => 'image', | ||
57 | + 'attribute'=>'img', | ||
58 | + ], | ||
59 | + [ | ||
42 | 'label' =>'Дата', | 60 | 'label' =>'Дата', |
43 | 'value' =>function ($data) { | 61 | 'value' =>function ($data) { |
44 | return date('Y-m-d', $data->dt); | 62 | return date('Y-m-d', $data->dt); |
@@ -56,7 +74,6 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -56,7 +74,6 @@ $this->params['breadcrumbs'][] = $this->title; | ||
56 | 'attribute2' => 'date_to', | 74 | 'attribute2' => 'date_to', |
57 | ]), | 75 | ]), |
58 | ], | 76 | ], |
59 | - //'img', | ||
60 | 77 | ||
61 | ['class' => 'yii\grid\ActionColumn'], | 78 | ['class' => 'yii\grid\ActionColumn'], |
62 | ], | 79 | ], |
backend/views/news/view.php
@@ -31,8 +31,8 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -31,8 +31,8 @@ $this->params['breadcrumbs'][] = $this->title; | ||
31 | 'id', | 31 | 'id', |
32 | 'name', | 32 | 'name', |
33 | 'code', | 33 | 'code', |
34 | - 'brief:ntext', | ||
35 | - 'content:ntext', | 34 | + 'brief:html', |
35 | + 'content:html', | ||
36 | 'sort_delete', | 36 | 'sort_delete', |
37 | 'title', | 37 | 'title', |
38 | 'kwords', | 38 | 'kwords', |
backend/views/page/_form.php
@@ -2,7 +2,8 @@ | @@ -2,7 +2,8 @@ | ||
2 | 2 | ||
3 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
4 | use yii\widgets\ActiveForm; | 4 | use yii\widgets\ActiveForm; |
5 | - | 5 | +use mihaildev\ckeditor\CKEditor; |
6 | +use mihaildev\elfinder\ElFinder; | ||
6 | /* @var $this yii\web\View */ | 7 | /* @var $this yii\web\View */ |
7 | /* @var $model common\models\Page */ | 8 | /* @var $model common\models\Page */ |
8 | /* @var $form yii\widgets\ActiveForm */ | 9 | /* @var $form yii\widgets\ActiveForm */ |
@@ -16,7 +17,14 @@ use yii\widgets\ActiveForm; | @@ -16,7 +17,14 @@ use yii\widgets\ActiveForm; | ||
16 | 17 | ||
17 | <?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?> | 18 | <?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?> |
18 | 19 | ||
19 | - <?= $form->field($model, 'content')->textarea(['rows' => 6]) ?> | 20 | + <?= $form->field($model, 'content')->widget(CKEditor::className(),[ |
21 | + 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ | ||
22 | + 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать | ||
23 | + 'inline' => false, //по умолчанию false]), | ||
24 | + 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('page/images-upload') | ||
25 | + ] | ||
26 | + ) | ||
27 | + ]); ?> | ||
20 | 28 | ||
21 | <?= $form->field($model, 'sort')->textInput() ?> | 29 | <?= $form->field($model, 'sort')->textInput() ?> |
22 | 30 | ||
@@ -26,7 +34,7 @@ use yii\widgets\ActiveForm; | @@ -26,7 +34,7 @@ use yii\widgets\ActiveForm; | ||
26 | 34 | ||
27 | <?= $form->field($model, 'descr')->textInput(['maxlength' => true]) ?> | 35 | <?= $form->field($model, 'descr')->textInput(['maxlength' => true]) ?> |
28 | 36 | ||
29 | - <?= $form->field($model, 'is_active')->textInput() ?> | 37 | + <?= $form->field($model, 'is_active')->checkbox() ?> |
30 | 38 | ||
31 | <div class="form-group"> | 39 | <div class="form-group"> |
32 | <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | 40 | <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
backend/views/page/index.php
@@ -25,15 +25,30 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -25,15 +25,30 @@ $this->params['breadcrumbs'][] = $this->title; | ||
25 | 'columns' => [ | 25 | 'columns' => [ |
26 | ['class' => 'yii\grid\SerialColumn'], | 26 | ['class' => 'yii\grid\SerialColumn'], |
27 | 27 | ||
28 | - 'id', | 28 | + //'id', |
29 | 'name', | 29 | 'name', |
30 | 'code', | 30 | 'code', |
31 | - 'content:ntext', | 31 | + //'content:ntext', |
32 | 'sort', | 32 | 'sort', |
33 | // 'title', | 33 | // 'title', |
34 | // 'kwords', | 34 | // 'kwords', |
35 | // 'descr', | 35 | // 'descr', |
36 | - // 'is_active', | 36 | + [ |
37 | + 'format' => 'raw', | ||
38 | + 'filter' => [ | ||
39 | + '1'=>'Отображаются', | ||
40 | + '0'=>'Скрытые', | ||
41 | + ], | ||
42 | + 'value' => function($data){ | ||
43 | + if($data->is_active){ | ||
44 | + $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>'; | ||
45 | + } else { | ||
46 | + $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>'; | ||
47 | + } | ||
48 | + return $status_img; | ||
49 | + }, | ||
50 | + 'attribute'=>'is_active', | ||
51 | + ], | ||
37 | 52 | ||
38 | ['class' => 'yii\grid\ActionColumn'], | 53 | ['class' => 'yii\grid\ActionColumn'], |
39 | ], | 54 | ], |
backend/views/slider/_form.php
@@ -14,11 +14,17 @@ use yii\widgets\ActiveForm; | @@ -14,11 +14,17 @@ use yii\widgets\ActiveForm; | ||
14 | 14 | ||
15 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | 15 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
16 | 16 | ||
17 | - <?= $form->field($model, 'img')->textInput(['maxlength' => true]) ?> | 17 | + <?= \backend\components\ImageUploader::widget([ |
18 | + 'model'=> $model, | ||
19 | + 'field'=>'img', | ||
20 | + 'multi'=>false, | ||
21 | + 'gallery' =>$model->img, | ||
22 | + 'name' => 'Загрузить картинку' | ||
23 | + ]); ?> | ||
18 | 24 | ||
19 | <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?> | 25 | <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?> |
20 | 26 | ||
21 | - <?= $form->field($model, 'is_active')->textInput() ?> | 27 | + <?= $form->field($model, 'is_active')->checkbox() ?> |
22 | 28 | ||
23 | <?= $form->field($model, 'sort')->textInput() ?> | 29 | <?= $form->field($model, 'sort')->textInput() ?> |
24 | 30 |
backend/views/slider/index.php
@@ -27,9 +27,32 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -27,9 +27,32 @@ $this->params['breadcrumbs'][] = $this->title; | ||
27 | 27 | ||
28 | 'id', | 28 | 'id', |
29 | 'name', | 29 | 'name', |
30 | - 'img', | ||
31 | - 'url:url', | ||
32 | - 'is_active', | 30 | + [ |
31 | + 'attribute'=>'img', | ||
32 | + 'format' => 'raw', | ||
33 | + 'value' => function($data){ | ||
34 | + return Html::img(\yii\helpers\Url::to($data->img),[ | ||
35 | + 'style' => 'width:200px;' | ||
36 | + ]); | ||
37 | + }, | ||
38 | + ], | ||
39 | + //'url:url', | ||
40 | + [ | ||
41 | + 'format' => 'raw', | ||
42 | + 'filter' => [ | ||
43 | + '1'=>'Отображаются', | ||
44 | + '0'=>'Скрытые', | ||
45 | + ], | ||
46 | + 'value' => function($data){ | ||
47 | + if($data->is_active){ | ||
48 | + $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>'; | ||
49 | + } else { | ||
50 | + $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>'; | ||
51 | + } | ||
52 | + return $status_img; | ||
53 | + }, | ||
54 | + 'attribute'=>'is_active', | ||
55 | + ], | ||
33 | // 'sort', | 56 | // 'sort', |
34 | 57 | ||
35 | ['class' => 'yii\grid\ActionColumn'], | 58 | ['class' => 'yii\grid\ActionColumn'], |
backend/web/.htaccess deleted
common/models/Emails.php
@@ -148,24 +148,25 @@ class Emails extends \yii\db\ActiveRecord | @@ -148,24 +148,25 @@ class Emails extends \yii\db\ActiveRecord | ||
148 | $letter = str_replace(array("../../../"),"http://".$_SERVER['SERVER_NAME']."/",$letter); | 148 | $letter = str_replace(array("../../../"),"http://".$_SERVER['SERVER_NAME']."/",$letter); |
149 | 149 | ||
150 | $mail = new \PHPMailer(); | 150 | $mail = new \PHPMailer(); |
151 | - | 151 | + $mail->CharSet = "UTF-8"; |
152 | $mail->From = $from; | 152 | $mail->From = $from; |
153 | - $mail->FromName = $from_name; | ||
154 | - $mail->Subject = $subject; | 153 | + $mail->FromName =$from_name; |
154 | + $mail->Subject =$subject; | ||
155 | $mail->MsgHTML($letter); | 155 | $mail->MsgHTML($letter); |
156 | $fp = fopen("Emails_log.txt","w"); | 156 | $fp = fopen("Emails_log.txt","w"); |
157 | fwrite($fp, $letter); | 157 | fwrite($fp, $letter); |
158 | fclose($fp); | 158 | fclose($fp); |
159 | - $splitEmails = explode(",",$to); | ||
160 | - if (count($splitEmails)>1){ | ||
161 | - foreach ($splitEmails as $sEmail){ | ||
162 | - $mail->AddAddress($sEmail); | ||
163 | - | ||
164 | - } | ||
165 | - | ||
166 | - } else { | ||
167 | - $mail->AddAddress($to); | ||
168 | - } | 159 | + $mail->AddAddress($to); |
160 | +// $splitEmails = explode(",",$to); | ||
161 | +// if (count($splitEmails)>1){ | ||
162 | +// foreach ($splitEmails as $sEmail){ | ||
163 | +// $mail->AddAddress($sEmail); | ||
164 | +// | ||
165 | +// } | ||
166 | +// | ||
167 | +// } else { | ||
168 | +// $mail->AddAddress($to); | ||
169 | +// } | ||
169 | 170 | ||
170 | if ($captcha){ | 171 | if ($captcha){ |
171 | if (md5($vars['code'])==$_SESSION['captcha_keystring']) { | 172 | if (md5($vars['code'])==$_SESSION['captcha_keystring']) { |
common/models/Page.php
@@ -51,14 +51,14 @@ class Page extends \yii\db\ActiveRecord | @@ -51,14 +51,14 @@ class Page extends \yii\db\ActiveRecord | ||
51 | { | 51 | { |
52 | return [ | 52 | return [ |
53 | 'id' => 'ID', | 53 | 'id' => 'ID', |
54 | - 'name' => 'Name', | ||
55 | - 'code' => 'Code', | ||
56 | - 'content' => 'Content', | ||
57 | - 'sort' => 'Sort', | ||
58 | - 'title' => 'Title', | ||
59 | - 'kwords' => 'Kwords', | ||
60 | - 'descr' => 'Descr', | ||
61 | - 'is_active' => 'Is Active', | 54 | + 'name' => 'Название', |
55 | + 'code' => 'Алиас', | ||
56 | + 'content' => 'Содержание', | ||
57 | + 'sort' => 'Сортировка', | ||
58 | + 'title' => 'SEO: Title', | ||
59 | + 'kwords' => 'SEO: Ключевые слова', | ||
60 | + 'descr' => 'SEO: Описание', | ||
61 | + 'is_active' => 'Выводить', | ||
62 | ]; | 62 | ]; |
63 | } | 63 | } |
64 | } | 64 | } |
common/models/Slider.php
@@ -44,11 +44,11 @@ class Slider extends \yii\db\ActiveRecord | @@ -44,11 +44,11 @@ class Slider extends \yii\db\ActiveRecord | ||
44 | { | 44 | { |
45 | return [ | 45 | return [ |
46 | 'id' => 'ID', | 46 | 'id' => 'ID', |
47 | - 'name' => 'Name', | ||
48 | - 'img' => 'Img', | ||
49 | - 'url' => 'Url', | ||
50 | - 'is_active' => 'Is Active', | ||
51 | - 'sort' => 'Sort', | 47 | + 'name' => 'Название', |
48 | + 'img' => 'Изображение', | ||
49 | + 'url' => 'Адрес перехода', | ||
50 | + 'is_active' => 'Выводить', | ||
51 | + 'sort' => 'Сортировка', | ||
52 | ]; | 52 | ]; |
53 | } | 53 | } |
54 | } | 54 | } |
frontend/controllers/NewsController.php
@@ -19,7 +19,7 @@ class NewsController extends Controller | @@ -19,7 +19,7 @@ class NewsController extends Controller | ||
19 | public function actionIndex() | 19 | public function actionIndex() |
20 | { | 20 | { |
21 | $dataProvider = new ActiveDataProvider([ | 21 | $dataProvider = new ActiveDataProvider([ |
22 | - 'query' => News::find(), | 22 | + 'query' => News::find()->where(['is_active'=>1]), |
23 | 'pagination' => [ | 23 | 'pagination' => [ |
24 | 'pageSize' => 16, | 24 | 'pageSize' => 16, |
25 | ], | 25 | ], |
@@ -32,8 +32,10 @@ class NewsController extends Controller | @@ -32,8 +32,10 @@ class NewsController extends Controller | ||
32 | 32 | ||
33 | public function actionView($translit) | 33 | public function actionView($translit) |
34 | { | 34 | { |
35 | + $news_list = News::find()->where(['is_active'=>1])->limit(3)->all(); | ||
35 | return $this->render('view', [ | 36 | return $this->render('view', [ |
36 | 'model' => $this->findModel($translit), | 37 | 'model' => $this->findModel($translit), |
38 | + 'news_list' => $news_list | ||
37 | ]); | 39 | ]); |
38 | } | 40 | } |
39 | 41 |
frontend/controllers/SiteController.php
@@ -3,6 +3,7 @@ namespace frontend\controllers; | @@ -3,6 +3,7 @@ namespace frontend\controllers; | ||
3 | 3 | ||
4 | use common\models\Accounts; | 4 | use common\models\Accounts; |
5 | use common\models\AccountsForm; | 5 | use common\models\AccountsForm; |
6 | +use common\models\News; | ||
6 | use common\models\Team; | 7 | use common\models\Team; |
7 | use common\models\TeamGroup; | 8 | use common\models\TeamGroup; |
8 | use Yii; | 9 | use Yii; |
@@ -51,6 +52,8 @@ class SiteController extends Controller | @@ -51,6 +52,8 @@ class SiteController extends Controller | ||
51 | { | 52 | { |
52 | $this->layout = '/outer'; | 53 | $this->layout = '/outer'; |
53 | 54 | ||
55 | + $news_list = News::find()->where(['is_active'=>1])->limit(3)->all(); | ||
56 | + | ||
54 | if (Yii::$app->request->post()) { | 57 | if (Yii::$app->request->post()) { |
55 | 58 | ||
56 | $post = Yii::$app->request->post(); | 59 | $post = Yii::$app->request->post(); |
@@ -64,7 +67,9 @@ class SiteController extends Controller | @@ -64,7 +67,9 @@ class SiteController extends Controller | ||
64 | } | 67 | } |
65 | 68 | ||
66 | } | 69 | } |
67 | - return $this->render('index'); | 70 | + return $this->render('index',[ |
71 | + 'news_list' => $news_list | ||
72 | + ]); | ||
68 | } | 73 | } |
69 | 74 | ||
70 | public function actionNotFound() | 75 | public function actionNotFound() |
frontend/views/news/view.php
1 | <?php | 1 | <?php |
2 | - | 2 | +use \yii\helpers\Html; |
3 | $this->registerCssFile('/css/style/news_all.css'); | 3 | $this->registerCssFile('/css/style/news_all.css'); |
4 | 4 | ||
5 | $this->title = $model->name; | 5 | $this->title = $model->name; |
@@ -19,18 +19,12 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -19,18 +19,12 @@ $this->params['breadcrumbs'][] = $this->title; | ||
19 | </div> | 19 | </div> |
20 | <div class='long_line'></div> | 20 | <div class='long_line'></div> |
21 | <div class="go_news"> | 21 | <div class="go_news"> |
22 | - <a href=""> | ||
23 | - <div class="back_news"> | ||
24 | - <p class='article'>Приход товара Mecarm</p> | ||
25 | - <p class="short_news">На склад поступила очередная партия товара MecArm</p> | ||
26 | - </div> | ||
27 | - </a> | ||
28 | - <a href=""> | ||
29 | - <div class="next_news"> | ||
30 | - <p class='article'>Приход товара Mecarm</p> | ||
31 | - <p class="short_news">На склад поступила очередная партия товара MecArm</p> | ||
32 | - </div> | ||
33 | - </a> | 22 | + <?php foreach ($news_list as $one_news):?> |
23 | + <div class="back_news"> | ||
24 | + <?= Html::a("<p class='article'>".$one_news->name."</p>",['news/view', 'translit' =>$one_news->code ]) ?> | ||
25 | + <?= Html::a("<p class='short_news'>".$one_news->brief."</p>",['news/view', 'translit' =>$one_news->code ]) ?> | ||
26 | + </div> | ||
27 | + <?php endforeach; ?> | ||
34 | </div> | 28 | </div> |
35 | </div> | 29 | </div> |
36 | <img src="/images/lonh_line.png" style="margin-top:-20px;opacity:0"> | 30 | <img src="/images/lonh_line.png" style="margin-top:-20px;opacity:0"> |
frontend/views/site/index.php
@@ -581,6 +581,14 @@ use \yii\helpers\Html; | @@ -581,6 +581,14 @@ use \yii\helpers\Html; | ||
581 | <span class="number_of">1/</span> | 581 | <span class="number_of">1/</span> |
582 | <span class="general_number">5</span> | 582 | <span class="general_number">5</span> |
583 | <span><img src="/images/arrow_slider_go.png"></span> | 583 | <span><img src="/images/arrow_slider_go.png"></span> |
584 | + <?php foreach ($news_list as $one_news):?> | ||
585 | + <div class="slider_tovars"> | ||
586 | + <div class="tovar"> | ||
587 | + <?= Html::img(\yii\helpers\Url::to($one_news->img)); ?> | ||
588 | + <?= Html::a("<p class='article'>".$one_news->name."</p>",['news/view', 'translit' =>$one_news->code ]) ?> | ||
589 | + </div> | ||
590 | + </div> | ||
591 | + <?php endforeach; ?> | ||
584 | <div class="slider_tovars"> | 592 | <div class="slider_tovars"> |
585 | <div class="tovar"> | 593 | <div class="tovar"> |
586 | <img src="/images/news.png"> | 594 | <img src="/images/news.png"> |