Commit fa743cfed69b7bc93a45a2744a6ddc09f00408e2

Authored by Yarik
1 parent 70753ad4

Catalog + home page complete

Showing 2 changed files with 34 additions and 4 deletions   Show diff stats
models/Category.php
@@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
23 * @property string $path 23 * @property string $path
24 * @property integer $depth 24 * @property integer $depth
25 * @property string $image 25 * @property string $image
  26 + * @property string $icon
26 * @property integer $product_unit_id 27 * @property integer $product_unit_id
27 * @property Product[] $products 28 * @property Product[] $products
28 * @property ProductUnit $productUnit 29 * @property ProductUnit $productUnit
@@ -54,7 +55,7 @@ @@ -54,7 +55,7 @@
54 * @property string|null $imageFile 55 * @property string|null $imageFile
55 * @property string|null $imageUrl 56 * @property string|null $imageUrl
56 * @method string|null getImageFile( int $field ) 57 * @method string|null getImageFile( int $field )
57 - * @method string|null getImageUrl( int $field ) 58 + * @method string|null getImageUrl( int $field, bool $dummy )
58 * * End SaveImgBehavior 59 * * End SaveImgBehavior
59 */ 60 */
60 class Category extends ActiveRecord 61 class Category extends ActiveRecord
@@ -78,6 +79,10 @@ @@ -78,6 +79,10 @@
78 'name' => 'image', 79 'name' => 'image',
79 'directory' => 'categories', 80 'directory' => 'categories',
80 ], 81 ],
  82 + [
  83 + 'name' => 'icon',
  84 + 'directory' => 'categories',
  85 + ],
81 ], 86 ],
82 ], 87 ],
83 ]; 88 ];
@@ -125,6 +130,7 @@ @@ -125,6 +130,7 @@
125 'path' => Yii::t('product', 'Path'), 130 'path' => Yii::t('product', 'Path'),
126 'depth' => Yii::t('product', 'Depth'), 131 'depth' => Yii::t('product', 'Depth'),
127 'image' => Yii::t('product', 'Image'), 132 'image' => Yii::t('product', 'Image'),
  133 + 'icon' => Yii::t('product', 'Icon'),
128 'imageUrl' => Yii::t('product', 'Image'), 134 'imageUrl' => Yii::t('product', 'Image'),
129 'product_unit_id' => Yii::t('product', 'Product Unit ID'), 135 'product_unit_id' => Yii::t('product', 'Product Unit ID'),
130 'remote_id' => Yii::t('product', 'Remote ID'), 136 'remote_id' => Yii::t('product', 'Remote ID'),
views/category/_form.php
@@ -64,9 +64,33 @@ @@ -64,9 +64,33 @@
64 'previewFileType' => 'image', 64 'previewFileType' => 'image',
65 ], 65 ],
66 ] 66 ]
67 - )  
68 - ->hint(  
69 - 'Для корректного отображения на сайте, размер изображения должен быть 262x144 либо соблюдать соотношение сторон примерно 2:1' 67 + ); ?>
  68 +
  69 + <?= $form->field($model, 'icon')
  70 + ->widget(
  71 + \kartik\file\FileInput::className(),
  72 + [
  73 + 'language' => 'ru',
  74 + 'options' => [
  75 + 'accept' => 'image/*',
  76 + 'multiple' => false,
  77 + ],
  78 + 'pluginOptions' => [
  79 + 'allowedFileExtensions' => [
  80 + 'jpg',
  81 + 'gif',
  82 + 'png',
  83 + ],
  84 + 'initialPreview' => !empty( $model->getImageUrl(1, false) ) ? ArtboxImageHelper::getImage(
  85 + $model->getImageUrl(1, false),
  86 + 'list'
  87 + ) : '',
  88 + 'overwriteInitial' => true,
  89 + 'showRemove' => false,
  90 + 'showUpload' => false,
  91 + 'previewFileType' => 'image',
  92 + ],
  93 + ]
70 ); ?> 94 ); ?>
71 95
72 <?= LanguageForm::widget( 96 <?= LanguageForm::widget(