products.php
11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?php
/** @var $this \yii\web\View */
/** @var $productProvider \yii\data\ActiveDataProvider */
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\widgets\Breadcrumbs;
use yii\web\View;
use common\modules\product\helpers\ProductHelper;
use common\modules\product\helpers\FilterHelper;
use frontend\widgets\Seo;
//$this->title = $category->categoryName->value;
$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : '';
$this->params['seo']['fields']['meta-title'] = $category->meta_title;
$this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name;
$this->params['seo']['seo_text'] = $category->seo_text;
$this->params['seo']['description'] = $category->meta_desc;
$this->params['seo']['meta'] = $category->meta_robots;
$this->params['seo']['category_name'] = $category->name;
//foreach($category->getParents()->all() as $parent) {
// $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
//}
$this->params['breadcrumbs'][] = ['label' => 'Каталог', 'url' => Url::to(['catalog/category']),'itemprop' => 'url', ];
$this->params['breadcrumbs'][] = $category->categoryName->value;
$this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css'));
$this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.skinHTML5.css'));
$this->registerJsFile(Yii::getAlias('@web/js/ion.rangeSlider.js'),[
'position' => View::POS_END,
'depends' => ['yii\web\JqueryAsset']
]);
?>
<script type="text/javascript">
<?php if ($priceLimits['min'] < $priceLimits['max']) :?>
$(document).ready(function() {
// price rangeslider (filter price slider)
$("#price_interval").ionRangeSlider({
type: "double",
min: <?= $priceLimits['min']?>,
max: <?= $priceLimits['max']?>,
from: <?= empty($filter['prices']['min']) ? $priceLimits['min'] : $filter['prices']['min']?>,
to: <?= empty($filter['prices']['max']) ? $priceLimits['max'] : $filter['prices']['max']?>,
grid: false,
onFinish: function(e) {
<?php
$filterWhitoutPrice = $filter;
$filterWhitoutPrice['prices'] = [
'min' => '{from}',
'max' => '{to}',
];
?>
var url = "<?= Url::to(['catalog/category', 'category' => $category, 'filters' => $filterWhitoutPrice])?>";
var from = e.from;
var to = e.to;
document.location = url.replace('{from}', from).replace('{to}', to);
}
});
});
<?php endif?>
</script>
<div class="loyout">
<div class="leftbar">
<?php /*
<img src="<?= Yii::$app->request->baseUrl ?>/img/new_coll.png" width="112" height="22"/><br/>
<img src="<?= Yii::$app->request->baseUrl ?>/img/pro.png" width="42" height="22"/>
*/?>
<div class="filters">
<ul>
<li class="new">
<?php
$checked = !empty($filter['special']) && in_array('new', $filter['special']);
$option_url = Url::to(['catalog/category', 'category' => $category, 'filters' => FilterHelper::getFilterForOption($filter, 'special', 'new', $checked)]);
?>
<input type="checkbox" class="special-option" <?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" />
<a href="<?= $option_url?>"><?= Yii::t('product', 'New products')?></a>
</li>
<li class="top">
<?php
$checked = !empty($filter['special']) && in_array('top', $filter['special']);
$option_url = Url::to(['catalog/category', 'category' => $category, 'filters' => FilterHelper::getFilterForOption($filter, 'special', 'top', $checked)]);
?>
<input type="checkbox" class="special-option" <?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" />
<a href="<?= $option_url?>"><?= Yii::t('product', 'Top products')?></a>
</li>
<li class="promo">
<?php
$checked = !empty($filter['special']) && in_array('promo', $filter['special']);
$option_url = Url::to(['catalog/category', 'category' => $category, 'filters' => FilterHelper::getFilterForOption($filter, 'special', 'promo', $checked)]);
?>
<input type="checkbox" class="special-option" <?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" />
<a href="<?= $option_url?>"><?= Yii::t('product', 'Promo products')?></a>
</li>
</ul>
</div>
<form action="#" name="filter_catalog_page_form" class="filter-catalog-form">
<?php if (!empty($filter)) :?>
<div class="filter_accept_bloc">
<!-- <button type="submit" class="filter_accept_btn">применить</button>-->
<a href="<?= Url::to(['catalog/category', 'category' => $category])?>" class="_form_checkbox_reset">сбросить фильтры</a>
</div>
<?php endif?>
<?php if ($brands) :?>
<div class="filters">
<div class="begin">Бренды</div>
<ul>
<?php foreach($brands as $brand) :
$checked = !empty($filter['brands']) && in_array($brand->alias, $filter['brands']);
//
$option_url = Url::to(['catalog/category', 'category' => $category, 'filters' => FilterHelper::getFilterForOption($filter, 'brands', $brand->alias, $checked)]);
?>
<li>
<input type="checkbox" onchange="document.location='<?= $option_url?>'" class="brands-option" <?= $checked ? ' checked' : ''?> />
<a href="<?= $option_url?>"><?= $brand->name?></a>
</li>
<?php endforeach?>
</ul>
</div>
<?php endif?>
<?php if (!empty($groups)) :?>
<?php
foreach($groups as $group_name => $group) {
?>
<div class="filters">
<div class="begin"><?= $group_name?></div>
<ul>
<?php foreach($group as $option) :
$checked = (isset($filter[$option['group_alias']]) && in_array($option['option_alias'], $filter[$option['group_alias']]));
$option_url = Url::to(['catalog/category', 'category' => $category, 'filters' => FilterHelper::getFilterForOption($filter, $option['group_alias'], $option['option_alias'], $checked)]);
?>
<li>
<input type="checkbox" onchange="document.location='<?= $option_url?>'" class="features-option" <?php /* name="option[<?= $group->alias?>][]"value="<?= $option->alias?>"*/?><?= $checked ? ' checked' : ''?> />
<a href="<?= $option_url?>"><?= $option['value']?></a>
</li>
<?php endforeach?>
</ul>
</div>
<?php
}
/*?>
<?php foreach($groups as $group) :?>
<div class="filters">
<div class="begin"><?= $group['name']?></div>
<ul>
<?php foreach($group->_options as $option) :
$checked = (isset($filter[$group->alias]) && in_array($option->alias, $filter[$group->alias]));
$option_url = Url::to(['catalog/category', 'category' => $category, 'filters' => FilterHelper::getFilterForOption($filter, $option->taxGroup->alias, $option->alias, $checked)]);
?>
<li>
<input type="checkbox" onchange="document.location='<?= $option_url?>'" class="features-option" <?php /* name="option[<?= $group->alias?>][]"value="<?= $option->alias?>"*//*?><?= $checked ? ' checked' : ''?> />
<a href="<?= $option_url?>"><?= $option->ValueRenderHTML?></a>
</li>
<?php endforeach?>
</ul>
</div>
<?php endforeach */?>
<?php endif?>
<?php if ($priceLimits['min'] < $priceLimits['max']) :?>
<div class="cost_box filters">
<div class="begin">Цена</div>
<div class="price_filter first_price_li">
<div class="price_slider">
<input type="text" id="price_interval" name="price_interval" value="" />
</div>
</div>
</div>
<?php endif?>
</form>
</div>
<div class="content" itemscope itemtype="http://schema.org/Product">
<div itemprop="name"><h1><?= Seo::widget([ 'row'=>'h1'])?></h1></div>
<div class="sort_menu">
<div class="sort_block">
<span>Сортировка:</span>
<?= \yii\widgets\LinkSorter::widget([
'sort' => $productProvider->sort,
'attributes' => [
'price',
]
]);
?>
</div>
</div>
<div class="products pn">
<ul>
<?php foreach($productProvider->models as $product) :?>
<?= $this->render('product_item', ['product' => $product])?>
<?php endforeach?>
</ul>
<div class="both"></div>
</div>
<?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?>
<?= \yii\widgets\LinkPager::widget([
'pagination' => $productProvider->pagination,
'options' => ['class' => 'pagination pull-right'],
'registerLinkTags' => true,
]);
?>
<?php endif?>
<div class="both"></div>
</div>
<div class="both"></div>
<?= \common\modules\product\widgets\specialProducts::widget(['type' => 'promo'])?>
<?= \common\modules\product\widgets\specialProducts::widget(['type' => 'new'])?>
<?= \common\modules\product\widgets\specialProducts::widget(['type' => 'top'])?>
<?= \common\modules\product\widgets\lastProducts::widget()?>
</div>
<?php
$seo_text = Seo::widget([ 'row'=>'seo_text']);
if($seo_text){
?>
<div class="text_seo hidden_seo text_seo_products">
<div>
<?= $seo_text?>
</div>
<a href="#" class="read_more_seo">Читать полностью</a>
</div>
<?php } ?>