Post by omar_ali222 » Wed Oct 01, 2014 9:11 pm

hello.
Can anyone help me in Filter module
Upon selected I want it automatically searches

Image
Last edited by omar_ali222 on Thu Oct 02, 2014 4:25 am, edited 3 times in total.

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by daugus » Wed Oct 01, 2014 11:55 pm

In catalog/view/theme/YOUR-THEME/template/module/filter.tlp

find this

Code: Select all

<script type="text/javascript"><!--
$('#button-filter').bind('click', function() {
	filter = [];
	
	$('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
		filter.push(this.value);
	});
	
	location = '<?php echo $action; ?>&filter=' + filter.join(',');
});
//--></script> 
and replace with this

Code: Select all

<script type="text/javascript">
$(document).ready(function() {

    $('#button-filter').hide();

    $('.box-filter input[type=\'checkbox\']').live('change', function() {
        filter = [];

        $('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
            filter.push(this.value);
        });

        location = '<?php echo $action; ?>&filter=' + filter.join(',');
    });
});
//--></script>
Now everytime you select certain filter the page reloads.

http://stackoverflow.com/questions/1962 ... mit-button

User avatar
Newbie

Posts

Joined
Wed Aug 27, 2014 7:51 pm

Post by omar_ali222 » Thu Oct 02, 2014 1:34 am

daugus wrote:In catalog/view/theme/YOUR-THEME/template/module/filter.tlp

find this

Code: Select all

<script type="text/javascript"><!--
$('#button-filter').bind('click', function() {
	filter = [];
	
	$('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
		filter.push(this.value);
	});
	
	location = '<?php echo $action; ?>&filter=' + filter.join(',');
});
//--></script> 
and replace with this

Code: Select all

<script type="text/javascript">
$(document).ready(function() {

    $('#button-filter').hide();

    $('.box-filter input[type=\'checkbox\']').live('change', function() {
        filter = [];

        $('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
            filter.push(this.value);
        });

        location = '<?php echo $action; ?>&filter=' + filter.join(',');
    });
});
//--></script>
Now everytime you select certain filter the page reloads.

http://stackoverflow.com/questions/1962 ... mit-button


daugus thank you very much sir , it works fine thanks .

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by omar_ali222 » Thu Oct 02, 2014 1:45 am

last question ?
how add clear filter

Image

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by daugus » Thu Oct 02, 2014 2:41 am

Solution was already posted in this tread:
http://forum.opencart.com/viewtopic.php?f=112&t=125737

User avatar
Newbie

Posts

Joined
Wed Aug 27, 2014 7:51 pm

Post by omar_ali222 » Thu Oct 02, 2014 3:08 am

I saw it but I didn't understand where could I put these

where I put this ??? ((($this->data['reload'] = $this->url->link('product/category', 'path=' . $this->request->get['path']); )))
and this ? (((( then add <?php echo $reload; ?> as a link for your button. ))) where I put this ?
and
where could I put thses ??

As for jQuery solution, you can add a class to the checkboxes, perhaps class="filter_checkboxes", then add a button into the template
CODE: SELECT ALL
onclick="$('.filter_checkboxes').attr('checked', 'false');"


help me

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by daugus » Thu Oct 02, 2014 3:31 am

Ok here are detailed instructions.

Open file /catalog/controller/module/filter.php

find this

Code: Select all

$this->data['button_filter'] = $this->language->get('button_filter');
paste this in next line

Code: Select all

$this->data['button_filter_clear'] = $this->language->get('button_filter_clear');

$this->data['reload'] = $this->url->link('product/category', 'path=' . $this->request->get['path']);
Open file /catalog/view/theme/YOUR-THEME/template/module/filter.tpl

find this

Code: Select all

<a id="button-filter" class="button"><?php echo $button_filter; ?></a>
paste this in next line

Code: Select all

<a href="<?php echo $reload; ?>" class="button"><?php echo $button_filter_clear; ?></a>
Open file /catalog/language/english/english.php

find this

Code: Select all

$_['button_filter']         = 'Refine Search';
paste this in next line

Code: Select all

$_['button_filter_clear']   = 'Clear All';
NOTE: you have to add this to every language!

That's it ;)

You can put [SOLVED] in thread name now, so others will know.
Last edited by daugus on Thu Oct 02, 2014 4:01 am, edited 1 time in total.

User avatar
Newbie

Posts

Joined
Wed Aug 27, 2014 7:51 pm

Post by omar_ali222 » Thu Oct 02, 2014 3:38 am

thanks daugus I'm grateful to you . but how could add another word whene I change language

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by daugus » Thu Oct 02, 2014 4:05 am

I have updated my upper post. It now supports multiple languages. Omar you'll have to modify your files again.

User avatar
Newbie

Posts

Joined
Wed Aug 27, 2014 7:51 pm

Post by omar_ali222 » Thu Oct 02, 2014 4:24 am

daugus > you'r the best thanks sir.I am thankful for your effort and I hope yours happiness.

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by omar_ali222 » Tue Oct 21, 2014 5:35 am

hello ,I hope help me ( daugus )

It doesn't work in Opencart 2.0 ( auto search when I select any option inside filter ,it doesn't work )

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by bluewizard » Thu Apr 23, 2015 10:13 pm

For version 2 change the JavaScript in the filter.tpl file to this

Code: Select all

    <script type="text/javascript"><!--
         $(document).ready(function() {
            $('#button-filter').hide();

            $('input[name^=\'filter\']').on('change', function() {
               filter = [];

		        $('input[name^=\'filter\']:checked').each(function(element) {
				   filter.push(this.value);
			});
        
            location = '<?php echo $action; ?>&filter=' + filter.join(',');
         });
    });
    //--></script>

Newbie

Posts

Joined
Thu Apr 23, 2015 10:12 pm

Post by stefg » Sun Nov 24, 2019 7:16 pm

How can we clear all filters at once in opencart 3?

New member

Posts

Joined
Fri Oct 18, 2019 7:25 pm
Location - Usa

Post by upotrebitel » Thu Jun 18, 2020 8:12 pm

stefg wrote:
Sun Nov 24, 2019 6:53 pm
How can we clear all filters at once in opencart 3?
1. Open file "catalog/view/theme/default/template/extension/module/filter.twig"

2. Replace:

Code: Select all

<div class="panel-heading">{{ heading_title }}</div>
with

Code: Select all

<div class="panel-heading">{{ heading_title }}
  <span class="reset_filters"><a href='{{ action }}'><i class="reset_filters_icon"></i>{{ clear_filters }}</a></span>
</div>
3. Add to the bottom of the file code:

Code: Select all

<script type="text/javascript">
$(document).ready(function() {
  $('input[name^=\'filter\']:checked').each(function(element) {
    $(".reset_filters").show();
  });
});
</script>
4. Open file "catalog/view/theme/default/stylesheet/stylesheet.css" and add to the bottom:

Code: Select all

.reset_filters {
  display: none;
  float: right;
}

.reset_filters a {
  color: #23a1d1;  /* or text color, that respond to your shop */
}

.reset_filters_icon {
  background: url(../image/red_x.png) no-repeat;
  display: inline-block;
  width: 11px;
  height: 12px;
  margin-right: 3px;
  margin-top: 2px;
}
5. Download attached file "red_x.png" and save it to folder ""catalog/view/theme/default/image"

6. Open file "catalog/language/en-gb/extension/module/filter.php" and add this line:

Code: Select all

$_['clear_filters'] = 'Reset All';
If you using different language, do this step with corresponding file.

Attachments

red_x.png

red_x.png (1.75 KiB) Viewed 2297 times


Newbie

Posts

Joined
Sun Jun 07, 2020 11:02 am
Who is online

Users browsing this forum: Amazon [Bot] and 60 guests