基本上我在类别上构建自定义过滤器,并希望使用$ _GET来过滤类别中的产品。我发现每当表单输入提交时,URL被重定向到index.php?color = 1而不是index.php?route = product / category& path = 59?color = 1.
任何人都可以解释一下吗?
本地主机\目录\视图\主题.... \ category.tpl
<div class="col-sm-1><!-- color -->
<spam>Color</spam>
</div>
<div class="col-sm-11 form-group">
<?php foreach ($details_color as $details_color) { ?>
<div class="checkbox pretty primary">
<?php if (isset($_GET[$details_color['name']])) { ?>
<input type="checkbox" name="<?php echo $details_color['name']; ?>" value="<?php echo $details_color['value'] ?>" onchange="this.form.submit()" checked>
<label><i class="fa fa-check"></i><?php echo $details_color['text']; ?></label>
<?php } else { ?>
<input type="checkbox" name="<?php echo $details_color['name']; ?>" value="<?php echo $details_color['value'] ?>" onchange="this.form.submit()">
<label><i class="fa fa-check"></i><?php echo $details_color['text']; ?></label>
<?php }?>
</div>
<?php } ?>
</div>
本地主机\目录\控制器\产品\ category.php
$array_details_color = array('black' => 'Black', 'blue' => 'Blue', 'brown' => 'Brown', 'cream' => 'Cream', 'crystal_color' => 'Crystal', 'gold' => 'Gold', 'gray' => 'Gray', 'green' => 'Green', 'orange' => 'Orange', 'pattern' => 'Pattern', 'pink' => 'Pink', 'purple' => 'Purple', 'red' => 'Red', 'silver' => 'Silver', 'tortoiseshell' => 'Tortoiseshell', 'translucent' => 'Translucent', 'white' => 'White', 'yellow' => 'Yellow');
$data['details_color'] = array();
foreach ($array_details_color as $key => $value) {
$data['details_color'][] = array (
'text' => $value,
'name' => $key,
'value' => 1
);
}
本地主机\目录\模型\目录\ product.php
$array_detail_color = array('black', 'blue', 'brown', 'cream', 'crystal_color', 'gold', 'gray', 'green', 'orange', 'pattern', 'pink', 'purple', 'red', 'silver', 'tortoiseshell', 'translucent', 'white', 'yellow');
foreach ($array_detail_color as $value) {
if (isset($_GET[$value])) {
$sql .= " AND pdtc.$value = 1 ";
}
}
答案 0 :(得分:1)
可能有更多的opencart特定方式来执行此操作,但一种简单的方法是采用您的表单并添加两个隐藏的输入。
<input type="hidden" name="route" value"product/category">
<input type="hidden" name="path" value="59">
确保它与您的复选框位于同一<form>
标记中,并且在循环外部,因此不会多次包含它。
答案 1 :(得分:0)
将参数添加到url中: -
?page = 1&amp; category = 12等没有?在url之间