Commit 2f93d129c9307988f154747d3c37c5f61d5fcf0b
1 parent
3d240292
-
Showing
13 changed files
with
684 additions
and
44 deletions
Show diff stats
1 | +<?php | |
2 | + | |
3 | +namespace common\components\artboximage; | |
4 | + | |
5 | +use kartik\file\FileInput; | |
6 | +use Yii; | |
7 | +use yii\base\Component; | |
8 | +use yii\base\ErrorException; | |
9 | +use yii\helpers\Html; | |
10 | +use yii\image\drivers\Image; | |
11 | + | |
12 | +//use common\components\artboximage\drivers\Image; | |
13 | + | |
14 | +class ArtboxImage extends Component { | |
15 | + | |
16 | + public $driver; | |
17 | + | |
18 | + public $presets = []; | |
19 | + | |
20 | + public $rootPath; | |
21 | + public $rootUrl; | |
22 | + | |
23 | + public $extensions = [ | |
24 | + 'jpg' => 'jpeg', | |
25 | + 'jpeg' => 'jpeg', | |
26 | + 'png' => 'png', | |
27 | + 'gif' => 'gif', | |
28 | + 'bmp' => 'bmp', | |
29 | + ]; | |
30 | + | |
31 | + public $uploadUrl = '/admin/artboxfile/action/upload'; | |
32 | + | |
33 | + public function load($file = null, $driver = null) { | |
34 | + if(empty($file) || !realpath($file)) { | |
35 | + throw new ErrorException('File name can not be empty and exists'); | |
36 | + } | |
37 | + return Image::factory($file, $driver ? $driver : $this->driver); | |
38 | + } | |
39 | + | |
40 | + public function fileinputWidget($model, $modelField, $formField = 'fileUpload', $multiple = false, $imageOnly = true) { | |
41 | + $options = [ | |
42 | + 'multiple' => $multiple, | |
43 | + ]; | |
44 | + if ($imageOnly) { | |
45 | + $options['accept'] = 'image/*'; | |
46 | + } | |
47 | + return FileInput::widget([ | |
48 | + 'name' => $formField, | |
49 | + 'options' => $options, | |
50 | + 'pluginOptions' => [ | |
51 | + 'allowedFileExtensions' => array_keys($this->extensions), | |
52 | + // @todo set for multiple | |
53 | + 'initialPreview' => $model->{$modelField} ? Html::img($model->{$modelField}) : '', | |
54 | + 'overwriteInitial' => !$multiple, | |
55 | + 'showRemove' => true, | |
56 | + 'showUpload' => false, | |
57 | + 'uploadUrl' => $this->uploadUrl, | |
58 | + 'uploadExtraData' => [ | |
59 | + 'fileField' => $modelField, | |
60 | + 'multiple' => intval($multiple), | |
61 | + ], | |
62 | + ], | |
63 | + 'pluginEvents' => [ | |
64 | + "change" => "function() { console.log('change'); }", | |
65 | + "open" => "function() { console.log('open'); }", | |
66 | + "save" => "function() { console.log('save'); }", | |
67 | + "upload" => "function() { console.log('upload'); }", | |
68 | + "uploaded" => "function() { console.log('uploaded'); }", | |
69 | + "filepreupload" => "function() { console.log('filepreupload'); }", | |
70 | + "fileuploaded" => "function(event, files, extra) { console.log(event, files, extra); }", | |
71 | + "fileuploaderror" => "function() { console.log('fileuploaderror'); }", | |
72 | + "filebatchuploaderror" => "function() { console.log('filebatchuploaderror'); }", | |
73 | + "filebatchuploadsuccess" => "function() { console.log('filebatchuploadsuccess'); }", | |
74 | + "filebatchuploadcomplete" => "function() { console.log('filebatchuploadcomplete'); }", | |
75 | + 'filebatchuploadsuccess' => "function(event, files, extra) { | |
76 | + console.log(event, files, extra); | |
77 | + }", | |
78 | + ], | |
79 | + ]); | |
80 | + } | |
81 | +} | |
0 | 82 | \ No newline at end of file | ... | ... |
common/components/artboximage/ArtboxImageHelper.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +namespace common\components\artboximage; | |
4 | + | |
5 | +use Yii; | |
6 | +use yii\base\Object; | |
7 | +use yii\helpers\ArrayHelper; | |
8 | +use yii\helpers\Html; | |
9 | +use yii\web\HttpException; | |
10 | + | |
11 | +class ArtboxImageHelper extends Object { | |
12 | + /** @var ArtboxImage $imageDriver */ | |
13 | + private static $imageDriver; | |
14 | + private static $presets; | |
15 | + | |
16 | + public function getDriver() { | |
17 | + if (empty(self::$imageDriver)) { | |
18 | + self::$imageDriver = Yii::$app->artboximage; | |
19 | + } | |
20 | + return self::$imageDriver; | |
21 | + } | |
22 | + | |
23 | + public function getPreset($preset) { | |
24 | + if (empty(self::$presets)) { | |
25 | + self::$presets = self::getDriver()->presets; | |
26 | + } | |
27 | + return empty(self::$presets[$preset]) ? null : self::$presets[$preset]; | |
28 | + } | |
29 | + | |
30 | + public static function getImage($file, $preset, $imgOptions = []) { | |
31 | + return Html::img(self::getImageSrc($file, $preset), $imgOptions); | |
32 | + } | |
33 | + | |
34 | + public static function getImageSrc($file, $preset, $preset_alias = null) { | |
35 | + if (is_string($preset)) { | |
36 | + $preset_alias = $preset; | |
37 | + $preset = self::getPreset($preset); | |
38 | + } | |
39 | + if (empty($preset) || empty($preset_alias)) { | |
40 | + return $file; | |
41 | + } | |
42 | + $filePath = self::getPathFromUrl($file); | |
43 | + if (!file_exists($filePath) || !preg_match('#^(.*)\.(' . self::getExtensionsRegexp() . ')$#', $file, $matches)) { | |
44 | + return $file; | |
45 | + } | |
46 | + return self::getPresetUrl($filePath, $preset, $preset_alias); | |
47 | + } | |
48 | + | |
49 | + public static function fileinputWidget($model, $modelField, $formField = 'fileUpload', $multiple = false) { | |
50 | + return Yii::$app->artboximage->fileinputWidget($model, $modelField, $formField, $multiple); | |
51 | + } | |
52 | + | |
53 | + private static function getPathFromUrl($url) { | |
54 | + return substr_replace($url, self::getDriver()->rootPath, 0, strlen(self::getDriver()->rootUrl)); | |
55 | + } | |
56 | + | |
57 | + private static function getUrlFromPath($path) { | |
58 | + return substr_replace($path, self::getDriver()->rootUrl, 0, strlen(self::getDriver()->rootPath)); | |
59 | + } | |
60 | + | |
61 | + private static function getPresetUrl($filePath, $preset, $preset_alias) { | |
62 | + $pathinfo = pathinfo($filePath); | |
63 | + $presetPath = $pathinfo['dirname'] .'/styles/'. strtolower($preset_alias); | |
64 | + $presetFilePath = $presetPath .'/'. $pathinfo['basename']; | |
65 | + $presetUrl = self::getUrlFromPath($presetFilePath); | |
66 | + if (file_exists($presetFilePath)) { | |
67 | + return $presetUrl; | |
68 | + } | |
69 | + if (!file_exists($presetPath)) { | |
70 | + @mkdir($presetPath, 0777, true); | |
71 | + } | |
72 | + $output = self::createPresetImage($filePath, $preset, $preset_alias); | |
73 | + if ( !empty($output) ) { | |
74 | + $f = fopen($presetFilePath, 'w'); | |
75 | + fwrite($f, $output); | |
76 | + fclose($f); | |
77 | + return $presetUrl; | |
78 | + } | |
79 | + return false; | |
80 | + } | |
81 | + | |
82 | + private static function createPresetImage($filePath, $preset, $preset_alias) | |
83 | + { | |
84 | + $image = self::getDriver()->load($filePath); | |
85 | + foreach ($preset as $action => $data) { | |
86 | + switch($action) { | |
87 | + case 'resize': | |
88 | + $image->resize($data['width'], $data['height'], @$data['master']); | |
89 | + break; | |
90 | + case 'flip': | |
91 | + $image->flip(@$data['direction']); | |
92 | + break; | |
93 | + default: | |
94 | + break; | |
95 | + } | |
96 | + } | |
97 | + return $image->render(); | |
98 | + } | |
99 | + | |
100 | + /** | |
101 | + * Get extensions regexp | |
102 | + * @return string regexp | |
103 | + */ | |
104 | + private function getExtensionsRegexp() | |
105 | + { | |
106 | + $keys = array_keys(self::getDriver()->extensions); | |
107 | + return '(?i)' . join('|', $keys); | |
108 | + } | |
109 | + | |
110 | + /** | |
111 | + * Get size from suffix | |
112 | + * @param string $suffix | |
113 | + * @return string size | |
114 | + */ | |
115 | + private function getSizeFromSuffix($suffix) | |
116 | + { | |
117 | + return array_search($suffix, $this->getSizeSuffixes()); | |
118 | + } | |
119 | + | |
120 | + /** | |
121 | + * Get suffix from size | |
122 | + * @param string $size | |
123 | + * @return string suffix | |
124 | + */ | |
125 | + private function getSufixFromSize($size) | |
126 | + { | |
127 | + return ArrayHelper::getValue($this->getSizeSuffixes(), $size); | |
128 | + } | |
129 | + | |
130 | + private function getSizeSuffixes() | |
131 | + { | |
132 | + $suffixes = []; | |
133 | + foreach ($this->sizes as $size => $sizeConf) { | |
134 | + $suffixes[$size] = ArrayHelper::getValue($this->sizeSuffixes, $size, $this->defaultSizeSuffix . $size); | |
135 | + } | |
136 | + return $suffixes; | |
137 | + } | |
138 | +} | |
0 | 139 | \ No newline at end of file | ... | ... |
common/config/main.php
... | ... | @@ -63,6 +63,66 @@ return [ |
63 | 63 | ], |
64 | 64 | ], |
65 | 65 | ], |
66 | + 'artboximage' => [ | |
67 | + 'class' => 'common\components\artboximage\ArtboxImage', | |
68 | + 'driver' => 'GD', //GD or Imagick | |
69 | + 'rootPath' => Yii::getAlias('@storage'), | |
70 | + 'rootUrl' => Yii::getAlias('/storage'), | |
71 | + 'presets' => [ | |
72 | + 'product' => [ | |
73 | + 'resize' => [ | |
74 | + 'width' => 300, | |
75 | + 'height' => 300, | |
76 | + 'master' => null | |
77 | + ], | |
78 | + /*'flip' => [ | |
79 | + 'direction' => \common\components\artboximage\drivers\Image::HORIZONTAL | |
80 | + ]*/ | |
81 | + ], | |
82 | + 'brandlist' => [ | |
83 | + 'resize' => [ | |
84 | + 'width' => 138, | |
85 | + 'height' => 78, | |
86 | + 'master' => null | |
87 | + ], | |
88 | + ], | |
89 | + 'product_trumb' => [ | |
90 | + 'resize' => [ | |
91 | + 'width' => 80, | |
92 | + 'height' => 80, | |
93 | + 'master' => null | |
94 | + ], | |
95 | + ], | |
96 | + 'product_list' => [ | |
97 | + 'resize' => [ | |
98 | + 'width' => 130, | |
99 | + 'height' => 70, | |
100 | + 'master' => null | |
101 | + ], | |
102 | + ], | |
103 | + 'product_list2' => [ | |
104 | + 'resize' => [ | |
105 | + 'width' => 130, | |
106 | + 'height' => 70, | |
107 | + 'master' => null | |
108 | + ], | |
109 | + ], | |
110 | + 'mainmenu' => [ | |
111 | + 'resize' => [ | |
112 | + 'width' => 160, | |
113 | + 'height' => 170, | |
114 | + 'master' => null | |
115 | + ], | |
116 | + ], | |
117 | + 'large' => [ | |
118 | + 'resize' => [ | |
119 | + 'width' => 600, | |
120 | + 'height' => 600, | |
121 | + 'master' => null | |
122 | + ], | |
123 | + ], | |
124 | + ] | |
125 | + ], | |
66 | 126 | ], |
67 | 127 | |
68 | 128 | 'modules' => [ | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace common\modules\artboxfile; | |
4 | + | |
5 | +/** | |
6 | + * product module definition class | |
7 | + */ | |
8 | +class Module extends \yii\base\Module | |
9 | +{ | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public $controllerNamespace = 'common\modules\artboxfile\controllers'; | |
14 | + | |
15 | + /** | |
16 | + * @inheritdoc | |
17 | + */ | |
18 | + public function init() | |
19 | + { | |
20 | + parent::init(); | |
21 | + | |
22 | + \Yii::configure($this, require(__DIR__.'/config.php')); | |
23 | + } | |
24 | +} | ... | ... |
common/modules/artboxfile/controllers/ActionController.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +namespace common\modules\artboxfile\controllers; | |
4 | + | |
5 | +use common\modules\artboxfile\models\File; | |
6 | +use Yii; | |
7 | +use yii\helpers\Html; | |
8 | +use yii\web\Controller; | |
9 | +use yii\web\UploadedFile; | |
10 | + | |
11 | +class ActionController extends Controller { | |
12 | + | |
13 | + public $tmpDir = '@storage/tmp'; | |
14 | + | |
15 | + public function actionUpload() { | |
16 | + $request = Yii::$app->request->post(); | |
17 | + | |
18 | + $multiple = !empty($request['multiple']); | |
19 | + $fileField = empty($request['fileField']) ? 'file' : $request['fileField']; | |
20 | + $formField = empty($request['formField']) ? 'fileUpload' : $request['formField']; | |
21 | + | |
22 | + | |
23 | + if($_FILES[$formField]) | |
24 | + { | |
25 | + if (($_FILES[$formField] == "none") OR (empty($_FILES[$formField]['name'])) ) | |
26 | + { | |
27 | + $error = "Вы не выбрали файл"; | |
28 | + } | |
29 | + else if ($_FILES[$formField]["size"] == 0 OR $_FILES[$formField]["size"] > 2050000) | |
30 | + { | |
31 | + $error = "Размер файла не соответствует нормам"; | |
32 | + } | |
33 | + /*else if (($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/png") AND ($_FILES['upload']['type'] != 'image/gif')) | |
34 | + { | |
35 | + $message = "Допускается загрузка только картинок JPG, GIF и PNG."; | |
36 | + }*/ | |
37 | + else if (!is_uploaded_file($_FILES[$formField]["tmp_name"])) | |
38 | + { | |
39 | + $error = "Что-то пошло не так. Попытайтесь загрузить файл ещё раз."; | |
40 | + } | |
41 | + else{ | |
42 | + $ext = $this->getex($_FILES[$formField]['name']); | |
43 | + $name = $_FILES[$formField]['name'] .'.'. $ext; | |
44 | + $tmpName = uniqid('tmpfile_') .'.'. $ext; | |
45 | + | |
46 | + $path = Yii::getAlias($this->tmpDir); | |
47 | + if(!is_dir($path)) { | |
48 | + mkdir($path, 0755, true); | |
49 | + } | |
50 | + | |
51 | + if (!move_uploaded_file($_FILES[$formField]['tmp_name'], $path .'/'. $tmpName)) { | |
52 | + $error = "File not uploaded"; | |
53 | + } else { | |
54 | + $full_path = $path .'/'. $tmpName; | |
55 | + $message = "Файл " . $_FILES[$formField]['name'] . " in $full_path загружен"; | |
56 | + } | |
57 | + } | |
58 | + } | |
59 | + if (!empty($error)) { | |
60 | + print json_encode(['error' => $error]); | |
61 | + } else { | |
62 | + $sendingData = [ | |
63 | + 'append' => $multiple, | |
64 | +// 'initialPreview' => Html::img() | |
65 | +// 'initialPreviewConfig' => , | |
66 | +// 'initialPreviewThumbTags' => , | |
67 | + | |
68 | + ]; | |
69 | + print json_encode(['message' => $message, 'tmpfile' => $full_path, 'filename' => $name]); | |
70 | + } | |
71 | + exit; | |
72 | + } | |
73 | + | |
74 | + protected function getex($filename) { | |
75 | + return end(explode(".", $filename)); | |
76 | + } | |
77 | +} | |
0 | 78 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace common\modules\artboxfile\models; | |
4 | + | |
5 | +use Yii; | |
6 | +use yii\db\ActiveRecord; | |
7 | + | |
8 | +class File extends ActiveRecord { | |
9 | + | |
10 | + public $fileUploadName; | |
11 | + | |
12 | + /** | |
13 | + * @inheritdoc | |
14 | + */ | |
15 | + public function rules() | |
16 | + { | |
17 | + return [ | |
18 | + [['file'], 'string', 'max' => 255], | |
19 | + [[$this->fileUploadName], 'safe'], | |
20 | + [[$this->fileUploadName], 'file', 'extensions' => 'jpg, gif, png'], | |
21 | + ]; | |
22 | + } | |
23 | + | |
24 | + /** | |
25 | + * @inheritdoc | |
26 | + */ | |
27 | + public function attributeLabels() | |
28 | + { | |
29 | + return [ | |
30 | + 'file' => Yii::t('artbox', 'File name'), | |
31 | + 'fileUpload' => Yii::t('artbox', 'File'), | |
32 | + ]; | |
33 | + } | |
34 | +} | |
0 | 35 | \ No newline at end of file | ... | ... |
frontend/config/main.php
... | ... | @@ -42,14 +42,17 @@ return [ |
42 | 42 | 'class' => 'iutbay\yii2imagecache\ImageCache', |
43 | 43 | 'sourcePath' => '@app/web/images', |
44 | 44 | 'sourceUrl' => '@web/images', |
45 | + 'thumbsPath' => '@app/web/thumbs', | |
46 | + 'thumbsUrl' => '@web/thumbs', | |
47 | + 'resizeMode' => 'inset', | |
45 | 48 | 'sizes' => [ |
46 | 49 | 'brandlist' => [128, 128], |
47 | 50 | 'product' => [300, 300], |
48 | 51 | 'product_trumb' => [80, 80], |
49 | 52 | 'product_trumb2' => [100, 100], |
50 | - 'product_list' => [130, 70], | |
53 | + 'list' => [134, 200], | |
51 | 54 | 'product_list2' => [130, 70], |
52 | - 'product_variant' => [40, 40], | |
55 | + 'product_variant' => [42, 42], | |
53 | 56 | 'mainmenu' => [160, 170], |
54 | 57 | 'large' => [600, 600], |
55 | 58 | ], |
... | ... | @@ -99,6 +102,8 @@ return [ |
99 | 102 | 'admin/catalog' => 'admin/catalog/index', |
100 | 103 | 'admin/catalog/save' => 'admin/catalog/save', |
101 | 104 | 'admin/catalog/delete' => 'admin/catalog/delete', |
105 | + | |
106 | + 'thumbs/<path:.*>' => 'site/thumb', | |
102 | 107 | ], |
103 | 108 | 'class' => 'common\components\urlManager\LangUrlManager', |
104 | 109 | 'languages' => ['ru', 'ua', 'en'], | ... | ... |
frontend/models/ProductFrontendSearch.php
... | ... | @@ -53,7 +53,7 @@ class ProductFrontendSearch extends Product { |
53 | 53 | } |
54 | 54 | // $query->joinWith('variant'); |
55 | 55 | $query->joinWith('brand'); |
56 | - $query->joinWith('image'); | |
56 | +// $query->joinWith('image'); | |
57 | 57 | $query->joinWith('categories'); |
58 | 58 | |
59 | 59 | $dataProvider = new ActiveDataProvider([ | ... | ... |
frontend/views/catalog/product.php
... | ... | @@ -92,8 +92,6 @@ $this->registerJs (" |
92 | 92 | <div class="alert-success"><?= $flash ?></div> |
93 | 93 | <?php endif; ?> |
94 | 94 | <div class="loyout"> |
95 | - | |
96 | - | |
97 | 95 | <div class="productLeftBar"> |
98 | 96 | <h1><?= $product->name ?></h1> |
99 | 97 | <div class="begin">Цветовые решения</div> |
... | ... | @@ -135,7 +133,6 @@ $this->registerJs (" |
135 | 133 | сравнение</a></li> |
136 | 134 | </ul> |
137 | 135 | </div> |
138 | - | |
139 | 136 | </div> |
140 | 137 | |
141 | 138 | <div class="productRightBar"> |
... | ... | @@ -158,8 +155,6 @@ $this->registerJs (" |
158 | 155 | </div> |
159 | 156 | |
160 | 157 | <div class="content"> |
161 | - | |
162 | - | |
163 | 158 | <div class="pic"> |
164 | 159 | <center> |
165 | 160 | <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= Yii::$app->imageCache->thumb($product->image->imageUrl, 'product')?></a> |
... | ... | @@ -167,14 +162,11 @@ $this->registerJs (" |
167 | 162 | </div> |
168 | 163 | <ul class="product_colors"> |
169 | 164 | <?php foreach ($product->images as $image): ?> |
170 | - <li><a href="<?= $image->imageUrl ?>" | |
171 | - rel="shadowbox[gal]"> | |
172 | - <?= Yii::$app->imageCache->thumb($variant->image->imageUrl, 'product_trumb2')?> | |
165 | + <li><a href="<?= $image->imageUrl ?>" rel="shadowbox[gal]"> | |
166 | + <?= Yii::$app->imageCache->thumb($image->imageUrl, 'product_trumb2')?> | |
173 | 167 | </a></li> |
174 | 168 | <?php endforeach; ?> |
175 | 169 | </ul> |
176 | - | |
177 | - | |
178 | 170 | </div> |
179 | 171 | <div class="both"></div> |
180 | 172 | </div> |
181 | 173 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | +/** @var $this \yii\web\View */ | |
3 | +/** @var $dataProvider \yii\data\ActiveDataProvider */ | |
4 | +$this->title = $product->name; | |
5 | +foreach($product->category->getParents()->all() as $parent) { | |
6 | + $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; | |
7 | +} | |
8 | +$this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]]; | |
9 | +$this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku; | |
10 | +?> | |
11 | +<h1 class="open_card_item_title"><?= $product->name .' '. $product->variant->name?></h1> | |
12 | + | |
13 | +<div class="item_3_blocks_wrap" id="one_item_block" data-id="<?= $product->variant->product_variant_id?>"> <!-- flex container --> | |
14 | + <div class="item_img_block"> <!-- блок с фотографиями --> | |
15 | + <div class="main_img"> | |
16 | + <?php if (empty($product->image)) :?> | |
17 | + <img src="/images/no_photo_big.png" alt="<?= $product->name?>"> | |
18 | + <?php else :?> | |
19 | + <img src="<?= $product->image->imageUrl?>" alt="<?= $product->image->alt ? $product->image->alt : $product->name?>"> | |
20 | + <?php endif?> | |
21 | + | |
22 | + <!--<span class="new">НОВИНКА</span> | |
23 | + <span class="top">ТОП</span>--> | |
24 | + </div> | |
25 | + <div class="product_service"> | |
26 | + <ul> | |
27 | + <li class="item1"><a id="add_to_bookmarks" href="#">Добавить в закладки</a> | |
28 | + </li> | |
29 | + <li class="item3"><a id="add_to_compare" href="#">Добавить в сравнение</a></li> | |
30 | + </ul> | |
31 | + </div> | |
32 | + <?php if (!empty($product->images)) :?> | |
33 | + <div class="main_img_slide"> | |
34 | + <?php foreach($product->images as $image) :?> | |
35 | + <div class="small_img_block active"> | |
36 | + <img src="<?= $image->imageUrl?>" alt="<?= $image->alt ? $image->alt : $product->name?>"> | |
37 | + </div> | |
38 | + <?php endforeach?> | |
39 | + | |
40 | + <img class="slider_arrow_right" src="/images/slider_right.png" alt=""> | |
41 | + <img class="slider_arrow_left" src="/images/slider_left.png" alt=""> | |
42 | + </div> | |
43 | + <?php endif?> | |
44 | + | |
45 | + </div> <!-- конец блока с фотографиями --> | |
46 | + | |
47 | + | |
48 | + <div class="busket_block"> <!-- блок с счетчиком и кнопкой добавить в корзину --> | |
49 | + <div class="top_code"> | |
50 | + <span class="code">Код: <?= $product->variant->sku?></span> | |
51 | + <span class="have"><img src="/images/ok_icon_green.png" alt=""><?= $product->stock !== 0 && $product->variant->price > 0 ? ' есть в наличии' : ' нет в наличии'?></span> | |
52 | + </div> | |
53 | + | |
54 | + <div class="grey_bg"> | |
55 | + <div class="counter"> | |
56 | + <?php if ($product->variant->price > 0) :?> | |
57 | + <div class="price"> | |
58 | + <?= $product->variant->price?> | |
59 | + </div> | |
60 | + <div class="sign">грн.</div> | |
61 | + <?php else :?> | |
62 | + <div class="price"></div> | |
63 | + <?php endif?> | |
64 | + | |
65 | + <div class="count_block"> | |
66 | + <input type="text" name="" class="form-control buy_one_item" value="1"> | |
67 | + <div class="count_buttons"> | |
68 | + <div class="button_plus">+</div> | |
69 | + <div class="button_minus">-</div> | |
70 | + </div> | |
71 | + </div> | |
72 | + </div> | |
73 | + | |
74 | + <div class="in_cart_btn"> | |
75 | + <a href="#"> | |
76 | + <button class="cart_btn" data-id="<?= $product->variant->product_variant_id?>"> в корзину <img src="/images/ico_basket_white.png" alt=""></button> | |
77 | + </a> | |
78 | + </div> | |
79 | + | |
80 | + <!--<div class="to_compare_link"> | |
81 | + <img src="/images/ico_scales.png" alt=""> | |
82 | + <a href="#" class="add_to_compare">добавить к сравнению</a> | |
83 | + </div>--> | |
84 | + </div> | |
85 | + <div class="quick_order"> | |
86 | + <form action=""> | |
87 | + <span class="text">БЫСТРЫЙ ЗАКАЗ</span> | |
88 | + <input type="text" class="quick_order_phone" name="quick_order_phone" placeholder="(0XX) XXX-XX-XX"> | |
89 | + <button type="submit">заказать</button> | |
90 | + </form> | |
91 | + </div> | |
92 | + | |
93 | + <div class="delivery"> | |
94 | + <p> | |
95 | + Доставка товара на следующий день после выставления счета. Мы доставим “День в <br> день” — уточните это у менеджера. | |
96 | + </p> | |
97 | + <a href="#">Подробно о доставке</a> | |
98 | + </div> | |
99 | + | |
100 | + </div><!-- конец блока с счетчиком и кнопкой добавить в корзину --> | |
101 | + | |
102 | + <div class="character_block"> <!-- блок с характеристиками --> | |
103 | + <?php if (!empty($properties)) :?> | |
104 | + <h3>Характеристики</h3> | |
105 | + <ul> | |
106 | + <?php foreach($properties as $group) :?> | |
107 | + <li> | |
108 | + <div class="each"> | |
109 | + <div class="title"><?= $group->name?></div> | |
110 | + <div class="tech"> | |
111 | + <?php foreach($group->_options as $option) :?> <?= $option->ValueRenderHTML?><?php endforeach?> | |
112 | + </div> | |
113 | + </div> | |
114 | + </li> | |
115 | + <?php endforeach?> | |
116 | + </ul> | |
117 | + <?php endif?> | |
118 | + | |
119 | + <!--<div class="tech_links"> | |
120 | + <a href="#">Описание</a> | |
121 | + <a href="#">Видео</a> | |
122 | + <a href="#">Отзывы(12)</a> | |
123 | + </div>--> | |
124 | + | |
125 | + </div><!-- закрытие блока с характеристиками --> | |
126 | + <hr> | |
127 | + | |
128 | + <h1 class="with_this">С этим товаром покупают</h1> | |
129 | + | |
130 | + <div class="flex_container"><!-- блок - с этим также покупают --> | |
131 | + | |
132 | + <div class="my_custom_card"> | |
133 | + <div class="new">АКЦИЯ</div> | |
134 | + <div class="top">Toп</div> | |
135 | + <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div> | |
136 | + <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a> | |
137 | + <div class="brand">Бренд: <span>Knauf</span></div> | |
138 | + <div class="type">Штукатурки</div> | |
139 | + <div class="price">102.05 <span>грн.</span></div> | |
140 | + <button class="basket_add_but">в корзину</button> | |
141 | + <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a> | |
142 | + <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | |
143 | + </div> | |
144 | + | |
145 | + <div class="my_custom_card"> | |
146 | + <div class="new">АКЦИЯ</div> | |
147 | + <div class="top">Toп</div> | |
148 | + <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div> | |
149 | + <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a> | |
150 | + <div class="brand">Бренд: <span>Knauf</span></div> | |
151 | + <div class="type">Штукатурки</div> | |
152 | + <div class="price">102.05 <span>грн.</span></div> | |
153 | + <button class="basket_add_but">в корзину</button> | |
154 | + <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a> | |
155 | + <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | |
156 | + </div> | |
157 | + | |
158 | + <div class="my_custom_card"> | |
159 | + <div class="new">АКЦИЯ</div> | |
160 | + <div class="top">Toп</div> | |
161 | + <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div> | |
162 | + <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a> | |
163 | + <div class="brand">Бренд: <span>Knauf</span></div> | |
164 | + <div class="type">Штукатурки</div> | |
165 | + <div class="price">102.05 <span>грн.</span></div> | |
166 | + <button class="basket_add_but">в корзину</button> | |
167 | + <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a> | |
168 | + <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | |
169 | + </div> | |
170 | + | |
171 | + <div class="my_custom_card"> | |
172 | + <div class="new">АКЦИЯ</div> | |
173 | + <div class="top">Toп</div> | |
174 | + <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div> | |
175 | + <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a> | |
176 | + <div class="brand">Бренд: <span>Knauf</span></div> | |
177 | + <div class="type">Штукатурки</div> | |
178 | + <div class="price">102.05 <span>грн.</span></div> | |
179 | + <button class="basket_add_but">в корзину</button> | |
180 | + <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a> | |
181 | + <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt=""> | |
182 | + </div> | |
183 | + | |
184 | + </div> <!-- конец блока - с этим также покупают --> | |
185 | + <div class="tabs_block"> <!-- Табы с описанием видео и отзывами --> | |
186 | + <div class="ionTabs" id="tabs_1" data-name="Tabs_Group_name"> | |
187 | + <ul class="ionTabs__head"> | |
188 | + <?php if (!empty($properties)) :?> | |
189 | + <li class="ionTabs__tab" data-target="Tab_1_name">Характеристики</li> | |
190 | + <?php endif?> | |
191 | + <?php if (TRUE || !empty($product->description)) :?> | |
192 | + <li class="ionTabs__tab" data-target="Tab_2_name">Описание</li> | |
193 | + <?php endif?> | |
194 | + <?php if (TRUE || !empty($product->video)) :?> | |
195 | + <li class="ionTabs__tab" data-target="Tab_3_name">Видео</li> | |
196 | + <?php endif?> | |
197 | +<!-- <li class="ionTabs__tab" data-target="Tab_4_name">Отзывы(12)</li>--> | |
198 | + </ul> | |
199 | + <div class="ionTabs__body"> | |
200 | + <?php if (!empty($properties)) :?> | |
201 | + <div class="ionTabs__item character_block" data-name="Tab_1_name"> | |
202 | + <ul> | |
203 | + <?php foreach($properties as $group) :?> | |
204 | + <li> | |
205 | + <div class="each"> | |
206 | + <div class="title"><?= $group->name?></div> | |
207 | + <div class="tech"> | |
208 | + <?php foreach($group->_options as $option) :?> <?= $option->ValueRenderHTML?><?php endforeach?> | |
209 | + </div> | |
210 | + </div> | |
211 | + </li> | |
212 | + <?php endforeach?> | |
213 | + </ul> | |
214 | + </div> | |
215 | + <?php else :?> | |
216 | + <?php endif?> | |
217 | + <?php if (!empty($product->description)) :?> | |
218 | + <div class="ionTabs__item" data-name="Tab_2_name"> | |
219 | + <?= $product->description?> | |
220 | + </div> | |
221 | + <?php endif?> | |
222 | + <?php if (!empty($product->video)) :?> | |
223 | + <div class="ionTabs__item" data-name="Tab_3_name"> | |
224 | + <?= $product->video?> | |
225 | + </div> | |
226 | + <?php endif?> | |
227 | + | |
228 | + <div class="ionTabs__preloader"></div> | |
229 | + </div> | |
230 | + </div> | |
231 | + | |
232 | + </div> <!-- конец табов с описанием видео и отзывами --> | |
233 | + <div style="clear: both;"></div> | |
234 | + | |
235 | + <?php if(!empty($last_products)) :?> | |
236 | + <hr> | |
237 | + <div class="watched_block"> | |
238 | + <h1>Вы недавно просматривали</h1> | |
239 | + <div class="flex-container"> | |
240 | + <?php foreach($last_products as $product) :?> | |
241 | + <?php require(__DIR__ .'/product_smart.php')?> | |
242 | + <?php endforeach?> | |
243 | + </div> | |
244 | + </div> | |
245 | + <?php endif?> | |
246 | + | |
247 | +</div> <!-- end flex container --> | ... | ... |
frontend/views/catalog/product_item.php
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | /** @var \common\modules\product\models\Product $product */ |
3 | 3 | use yii\helpers\Url; |
4 | 4 | ?> |
5 | -<li class="item" data-id="<?= $product->product_id?>"<?= (empty($product->variant) ? ' style="opacity: 0.5"' : '')?>> | |
5 | +<li class="item"> | |
6 | 6 | <div class="boxitem"> |
7 | 7 | <div class="pixbox"> |
8 | 8 | <a href="<?= Url::to([ |
... | ... | @@ -12,7 +12,7 @@ use yii\helpers\Url; |
12 | 12 | <?php if (empty($product->image)) :?> |
13 | 13 | <img src="/img/no_photo.png"> |
14 | 14 | <?php else :?> |
15 | - <?= Yii::$app->imageCache->thumb($product->image->imageUrl, 'product_list')?> | |
15 | + <?= Yii::$app->imageCache->thumb($product->image->imageUrl, 'list')?> | |
16 | 16 | <?php endif?> |
17 | 17 | </a> |
18 | 18 | </div> |
... | ... | @@ -52,7 +52,7 @@ use yii\helpers\Url; |
52 | 52 | 'catalog/product', |
53 | 53 | 'product' => $product, |
54 | 54 | '#' => 'm' . $variant->product_variant_id]) ?>"> |
55 | - <?= Yii::$app->imageCache->thumb($variant->image->imageUrl, 'product_list')?> | |
55 | + <?= Yii::$app->imageCache->thumb($variant->image->imageUrl, 'product_variant')?> | |
56 | 56 | </a> |
57 | 57 | </li> |
58 | 58 | <?php endif; ?> | ... | ... |
frontend/views/catalog/products.php
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | |
7 | 7 | use yii\helpers\Url; |
8 | 8 | use yii\widgets\Breadcrumbs; |
9 | +use yii\web\View; | |
9 | 10 | use common\modules\product\helpers\ProductHelper; |
10 | 11 | |
11 | 12 | $this->title = $category->categoryName->value; |
... | ... | @@ -19,35 +20,12 @@ $this->params['seo']['h1'] = 'TEST H1'; |
19 | 20 | $this->params['seo']['description'] = 'TEST DESCRIPTION'; |
20 | 21 | $this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD'; |
21 | 22 | $this->params['seo']['key']= 'product_list'; |
23 | + | |
24 | +$this->registerCssFile (Yii::$app->request->BaseUrl . '/css/begunok.css'); | |
25 | +$this->registerJsFile (Yii::$app->request->baseUrl . '/js/jquery.ui-slider.js', ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]); | |
26 | +$this->registerJsFile (Yii::$app->request->baseUrl . '/js/begunok.js', ['position' => View::POS_HEAD, 'depends' => ['yii\web\JqueryAsset']]); | |
22 | 27 | ?> |
23 | -<script type="text/javascript"> | |
24 | -<?php if ($priceLimits['min'] < $priceLimits['max']) :?> | |
25 | - $(document).ready(function() { | |
26 | - // price rangeslider (filter price slider) | |
27 | - $("#price_interval").ionRangeSlider({ | |
28 | - type: "double", | |
29 | - min: <?= $priceLimits['min']?>, | |
30 | - max: <?= $priceLimits['max']?>, | |
31 | - from: <?= empty($filter['prices']['min']) ? $priceLimits['min'] : $filter['prices']['min']?>, | |
32 | - to: <?= empty($filter['prices']['max']) ? $priceLimits['max'] : $filter['prices']['max']?>, | |
33 | - grid: false, | |
34 | - onFinish: function(e) { | |
35 | -<?php | |
36 | -$filterWhitoutPrice = $filter; | |
37 | -$filterWhitoutPrice['prices'] = [ | |
38 | - 'min' => '{from}', | |
39 | - 'max' => '{to}', | |
40 | -]; | |
41 | -?> | |
42 | - var url = "<?= Url::to(['catalog/category', 'category' => $category, 'filter' => $filterWhitoutPrice])?>"; | |
43 | - var from = e.from; | |
44 | - var to = e.to; | |
45 | - document.location = url.replace('{from}', from).replace('{to}', to); | |
46 | - } | |
47 | - }); | |
48 | - }); | |
49 | -<?php endif?> | |
50 | -</script> | |
28 | + | |
51 | 29 | |
52 | 30 | <nav class="bread-crumbs"> |
53 | 31 | <?= Breadcrumbs::widget ([ |
... | ... | @@ -134,6 +112,7 @@ $filterWhitoutPrice['prices'] = [ |
134 | 112 | <?= \yii\widgets\LinkPager::widget([ |
135 | 113 | 'pagination' => $productProvider->pagination, |
136 | 114 | 'options' => ['class' => 'pagination pull-right'], |
115 | + 'registerLinkTags' => true, | |
137 | 116 | ]); |
138 | 117 | ?> |
139 | 118 | <?php endif?> | ... | ... |