Commit fa743cfed69b7bc93a45a2744a6ddc09f00408e2
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 | 23 | * @property string $path |
| 24 | 24 | * @property integer $depth |
| 25 | 25 | * @property string $image |
| 26 | + * @property string $icon | |
| 26 | 27 | * @property integer $product_unit_id |
| 27 | 28 | * @property Product[] $products |
| 28 | 29 | * @property ProductUnit $productUnit |
| ... | ... | @@ -54,7 +55,7 @@ |
| 54 | 55 | * @property string|null $imageFile |
| 55 | 56 | * @property string|null $imageUrl |
| 56 | 57 | * @method string|null getImageFile( int $field ) |
| 57 | - * @method string|null getImageUrl( int $field ) | |
| 58 | + * @method string|null getImageUrl( int $field, bool $dummy ) | |
| 58 | 59 | * * End SaveImgBehavior |
| 59 | 60 | */ |
| 60 | 61 | class Category extends ActiveRecord |
| ... | ... | @@ -78,6 +79,10 @@ |
| 78 | 79 | 'name' => 'image', |
| 79 | 80 | 'directory' => 'categories', |
| 80 | 81 | ], |
| 82 | + [ | |
| 83 | + 'name' => 'icon', | |
| 84 | + 'directory' => 'categories', | |
| 85 | + ], | |
| 81 | 86 | ], |
| 82 | 87 | ], |
| 83 | 88 | ]; |
| ... | ... | @@ -125,6 +130,7 @@ |
| 125 | 130 | 'path' => Yii::t('product', 'Path'), |
| 126 | 131 | 'depth' => Yii::t('product', 'Depth'), |
| 127 | 132 | 'image' => Yii::t('product', 'Image'), |
| 133 | + 'icon' => Yii::t('product', 'Icon'), | |
| 128 | 134 | 'imageUrl' => Yii::t('product', 'Image'), |
| 129 | 135 | 'product_unit_id' => Yii::t('product', 'Product Unit ID'), |
| 130 | 136 | 'remote_id' => Yii::t('product', 'Remote ID'), | ... | ... |
views/category/_form.php
| ... | ... | @@ -64,9 +64,33 @@ |
| 64 | 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 | 96 | <?= LanguageForm::widget( | ... | ... |