Commit c11497bade87433e0fc6311f353335a2c905e353
1 parent
92f214e8
Brand images
Showing
2 changed files
with
56 additions
and
35 deletions
Show diff stats
common/behaviors/SaveImgBehavior.php
... | ... | @@ -79,17 +79,24 @@ |
79 | 79 | $directory = $fieldset[ 'directory' ]; |
80 | 80 | return empty( $this->owner->$name ) ? NULL : '/storage/' . $directory . '/' . $this->owner->$name; |
81 | 81 | } |
82 | - | |
82 | + | |
83 | 83 | /** |
84 | - * @param int $field | |
84 | + * @param int $field | |
85 | + * @param bool $dummy | |
85 | 86 | * |
86 | 87 | * @return null|string |
87 | 88 | */ |
88 | - public function getImageUrl($field = 0) | |
89 | + public function getImageUrl($field = 0, $dummy = true) | |
89 | 90 | { |
90 | 91 | $fieldset = $this->fields[ $field ]; |
91 | 92 | $name = $fieldset[ 'name' ]; |
92 | 93 | $directory = $fieldset[ 'directory' ]; |
93 | - return empty( $this->owner->$name ) ? NULL : '/storage/' . $directory . '/' . $this->owner->$name; | |
94 | + if(!empty($this->owner->$name)) { | |
95 | + return '/storage/'.$directory.'/'.$this->owner->$name; | |
96 | + } elseif ($dummy) { | |
97 | + return '/storage/no-image.png'; | |
98 | + } else { | |
99 | + return null; | |
100 | + } | |
94 | 101 | } |
95 | 102 | } |
96 | 103 | \ No newline at end of file | ... | ... |
frontend/views/filter/category-brand.php
... | ... | @@ -23,50 +23,64 @@ |
23 | 23 | ], |
24 | 24 | ]; |
25 | 25 | $this->params[ 'breadcrumbs' ][] = [ |
26 | - 'label' => \Yii::t('product', 'Brands').' '.$category->lang->name, | |
26 | + 'label' => \Yii::t('product', 'Brands') . ' ' . $category->lang->name, | |
27 | 27 | 'url' => [ |
28 | 28 | 'filter/category-brands', |
29 | 29 | 'category_id' => $category->category_id, |
30 | 30 | ], |
31 | 31 | ]; |
32 | 32 | $this->params[ 'breadcrumbs' ][] = $this->title; |
33 | + | |
34 | + $emptyBrand = false; | |
35 | + if (!$category->getImageUrl(0, false) || !$brand->getImageUrl(0, false) || empty( $brand->lang->seo_text )) { | |
36 | + $emptyBrand = true; | |
37 | + } | |
33 | 38 | ?> |
34 | 39 | <div class="section-box box-title-1 uppercase"><?= $this->title ?></div> |
35 | 40 | <div class="section-box box-brand margin_bottom_30"> |
36 | 41 | <div class="row"> |
37 | - <div class="style" style="position: relative"> | |
38 | - <div class="col-xs-12 col-sm-6 col-md-6"> | |
39 | - <div class="style article-img"> | |
40 | - <?php | |
41 | - echo ArtboxImageHelper::getImage($category->getImageUrl(), 'article_list'); | |
42 | - ?> | |
43 | - </div> | |
44 | - </div> | |
45 | - <div class="col-xs-12 col-sm-6 col-md-6" style="position: relative;z-index: 2"> | |
46 | - <div class="style brand-main-txt"> | |
47 | - <?php | |
48 | - echo $brand->lang->seo_text; | |
49 | - ?> | |
42 | + <?php | |
43 | + if (!$emptyBrand) { | |
44 | + ?> | |
45 | + <div class="style" style="position: relative"> | |
46 | + <div class="col-xs-12 col-sm-6 col-md-6"> | |
47 | + <div class="style article-img"> | |
48 | + <?php | |
49 | + echo ArtboxImageHelper::getImage($category->getImageUrl(), 'article_list'); | |
50 | + ?> | |
51 | + </div> | |
52 | + </div> | |
53 | + <div class="col-xs-12 col-sm-6 col-md-6" style="position: relative;z-index: 2"> | |
54 | + <div class="style brand-main-txt"> | |
55 | + <?php | |
56 | + echo $brand->lang->seo_text; | |
57 | + ?> | |
58 | + </div> | |
59 | + </div> | |
60 | + <div class="brand-txt-img"> | |
61 | + <?php | |
62 | + echo ArtboxImageHelper::getImage($brand->getImageUrl(), 'brand_image_filter'); | |
63 | + ?> | |
64 | + </div> | |
50 | 65 | </div> |
51 | - </div> | |
52 | - <div class="brand-txt-img"> | |
53 | 66 | <?php |
54 | - echo ArtboxImageHelper::getImage($brand->getImageUrl(), 'brand_image_filter'); | |
55 | - ?> | |
56 | - </div> | |
57 | - </div> | |
67 | + } | |
68 | + ?> | |
58 | 69 | <?php |
59 | - echo ListView::widget([ | |
60 | - 'dataProvider' => $dataProvider, | |
61 | - 'itemView' => '_brand_item', | |
62 | - 'itemOptions' => [ | |
63 | - 'class' => 'brands-list_', | |
64 | - ], | |
65 | - 'options' => [ | |
66 | - 'class' => 'style brands-list-wr', | |
67 | - ], | |
68 | - 'layout' => '{items}', | |
69 | - ]); | |
70 | + echo ListView::widget( | |
71 | + [ | |
72 | + 'dataProvider' => $dataProvider, | |
73 | + 'itemView' => '_brand_item', | |
74 | + 'itemOptions' => [ | |
75 | + 'class' => 'brands-list_', | |
76 | + ], | |
77 | + 'options' => [ | |
78 | + 'class' => 'style brands-list-wr', | |
79 | + 'style' => $emptyBrand?'margin-top: 0':'', | |
80 | + ], | |
81 | + 'layout' => '{items}', | |
82 | + ] | |
83 | + ); | |
70 | 84 | ?> |
71 | 85 | </div> |
72 | 86 | </div> |
73 | 87 | \ No newline at end of file | ... | ... |