diff --git a/components/Product.php b/components/Product.php index 3a5f55b..6f6cb29 100644 --- a/components/Product.php +++ b/components/Product.php @@ -30,6 +30,12 @@ public function defineProperties() 'addButtonText' => [ 'title' => 'Buy button text', ], + 'mainImageSize' => [ + 'title' => 'Main Image Size', + ], + 'subImageSize' => [ + 'title' => 'Secondary Image Size', + ], 'rowClass' => [ 'title' => 'Row', 'group' => 'CSS Classes', @@ -39,8 +45,20 @@ public function defineProperties() 'title' => 'Image', 'group' => 'CSS Classes', ], - 'productContainerClass' => [ - 'title' => 'Product container', + 'imageLinkClass' => [ + 'title' => 'Image Link', + 'group' => 'CSS Classes', + ], + 'mainImageContainerClass' => [ + 'title' => 'Main Image Container', + 'group' => 'CSS Classes', + ], + 'subImageContainerClass' => [ + 'title' => 'Secondary Image Containers', + 'group' => 'CSS Classes', + ], + 'imagesetContainerClass' => [ + 'title' => 'Imageset Container', 'group' => 'CSS Classes', ], 'detailContainerClass' => [ @@ -95,8 +113,12 @@ public function prepareVars() $this->addButtonText = $this->page['addButtonText'] = $this->property('addButtonText'); $this->rowClass = $this->page['rowClass'] = $this->property('rowClass'); $this->imageClass = $this->page['imageClass'] = $this->property('imageClass'); - $this->imageContainerClass = $this->page['imageContainerClass'] = $this->property('imageContainerClass'); - $this->productContainerClass = $this->page['productContainerClass'] = $this->property('productContainerClass'); + $this->imageLinkClass = $this->page['imageLinkClass'] = $this->property('imageLinkClass'); + $this->mainImageSize = $this->page['mainImageSize'] = $this->property('mainImageSize'); + $this->mainImageContainerClass = $this->page['mainImageContainerClass'] = $this->property('mainImageContainerClass'); + $this->subImageSize = $this->page['subImageSize'] = $this->property('subImageSize'); + $this->subImageContainerClass = $this->page['subImageContainerClass'] = $this->property('subImageContainerClass'); + $this->imagesetContainerClass = $this->page['imagesetContainerClass'] = $this->property('imagesetContainerClass'); $this->detailContainerClass = $this->page['detailContainerClass'] = $this->property('detailContainerClass'); $this->qtyClass= $this->page['qtyClass'] = $this->property('qtyClass'); $this->qtyWrapperClass= $this->page['qtyWrapperClass'] = $this->property('qtyWrapperClass'); @@ -112,7 +134,10 @@ public function loadProduct() { $productId = $this->propertyOrParam('idParam'); - return ShopProduct::whereSlug($productId)->first(); + return ShopProduct::whereSlug($productId)->with(['images' => function($query) + { + $query->orderBy('sort_order', 'asc'); + }])->first(); } } diff --git a/components/product/default.htm b/components/product/default.htm index 20df6ea..1441f16 100644 --- a/components/product/default.htm +++ b/components/product/default.htm @@ -1,6 +1,20 @@ -
-
- {{ product.title }} +
+
+
+ {% for image in product.images %} +
+ + {{ product.title }} + +
+ {% endfor %} +
diff --git a/models/Product.php b/models/Product.php index 148a9f7..1502866 100644 --- a/models/Product.php +++ b/models/Product.php @@ -36,13 +36,20 @@ class Product extends Model public $morphOne = []; public $morphMany = []; public $attachOne = []; - public $attachMany = []; + public $attachMany = [ + 'images' => ['System\Models\File'] + ]; public function getCategoryIdOptions($keyValue = null) { return Category::lists('title', 'id'); } + public function getSquareThumb($size, $image) + { + return $image->getThumb($size, $size, ['mode' => 'crop']); + } + public function setUrl($pageName, $controller) { $params = [ diff --git a/models/product/fields.yaml b/models/product/fields.yaml index 12ae063..90c5756 100644 --- a/models/product/fields.yaml +++ b/models/product/fields.yaml @@ -33,3 +33,10 @@ tabs: label: Description type: Backend\FormWidgets\RichEditor tab: Details + + images: + type: Backend\FormWidgets\FileUpload + mode: image + imageHeight: 260 + imageWidth: 260 + tab: Images