Post by calimero1 » Tue Feb 19, 2019 3:32 pm

Hi,
I am trying to change default checkbox filtering menu to dropdown selection box.
I have changed the code in catalog/view/theme/default/template/extension/module/filter.twig
Now it looks like this:

Code: Select all

    <select>
          <option></option>
      <div id="filter-group{{ filter_group.filter_group_id }}">{% for filter in filter_group.filter %}
        {% if filter.filter_id in filter_category %}    
           <option value="{{ filter.filter_id }}" id="{{ filter.filter_id }}" selected>{{ filter.name }}</option>
        {% else %}
           <option value="{{ filter.filter_id }}" id="{{ filter.filter_id }}">{{ filter.name }}</option> 
        {% endif %}     
     {% endfor %}</div>
    </select>
Now the dropdown selection box is displayed correctly, but when I choose some option from dropdown menu it does not do anything.

Any idea?

Many thanks.

Newbie

Posts

Joined
Sun Nov 04, 2018 6:45 am

Post by thekrotek » Tue Feb 19, 2019 4:35 pm

And you want it to do what exactly?

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by calimero1 » Tue Feb 19, 2019 5:16 pm

thekrotek wrote:
Tue Feb 19, 2019 4:35 pm
And you want it to do what exactly?
Hi,
I want to have Filter with dropdown menu items instead of checkboxes.
E.g. I have filter group "Color" with filters like "red", "blue", "green".
Now, if i choose "red" from my dropdown menu and click the "Refine Search" button, it does not do anything.

Newbie

Posts

Joined
Sun Nov 04, 2018 6:45 am

Post by thekrotek » Tue Feb 19, 2019 5:30 pm

Again, what do you want it to do exactly? Nobody understands "doesn't do anything", "doesn't work", "nothing happens" and similar issue descriptions.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by calimero1 » Tue Feb 19, 2019 5:51 pm

thekrotek wrote:
Tue Feb 19, 2019 5:30 pm
Again, what do you want it to do exactly? Nobody understands "doesn't do anything", "doesn't work", "nothing happens" and similar issue descriptions.
Hi,
I talk about the Filter extension. So if I choose "red" filter from dropdown and push "Refine Search" button only products with "red" filter assigned should be displayed. Now it displays all products from the category as if no filter has been selected.
I want exactly this, but for OpenCart 3:
viewtopic.php?t=104646

Thanks.

Newbie

Posts

Joined
Sun Nov 04, 2018 6:45 am

Post by thekrotek » Tue Feb 19, 2019 7:41 pm

That's weird... You copied a link from the same topic, but for 1.5, which I hope you read. And yet you've made only half of the changes. Of course, it won't work.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by calimero1 » Tue Feb 19, 2019 11:46 pm

thekrotek wrote:
Tue Feb 19, 2019 7:41 pm
That's weird... You copied a link from the same topic, but for 1.5, which I hope you read. And yet you've made only half of the changes. Of course, it won't work.
Oh, sorry. Now I have changed also javascript code and finally it works!
Thank you.

Newbie

Posts

Joined
Sun Nov 04, 2018 6:45 am

Post by paulfeakins » Wed Feb 20, 2019 6:24 pm

thekrotek wrote:
Tue Feb 19, 2019 5:30 pm
Again, what do you want it to do exactly? Nobody understands "doesn't do anything", "doesn't work", "nothing happens" and similar issue descriptions.
I'm glad it's not just me who really struggles to understand what people actually mean in the forum :drunk:

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by eric47905 » Wed Aug 28, 2019 1:09 pm

Ok, I did the first part of changes as outlined above, but I couldn't find where to make the javascript change, because the file in opencart 3 doesn't match what is shown in the 1.5 instructions in the link. The opencart 3 javascript at the bottom in the extension>module>filter.twig file is already commented out, and doesnt match the .box-filter anyways, it shows as $('#button-filter').on('click', function() {

Here are the rest of the instructions from the opencart version 1.5 instructions from above.

Code: Select all

Step 3:
Replace this code:

$('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
with:

$('.box-filter select option:selected').each(function(element) {

Finally:
Add this code to your stylesheet:
.box-filter select {
width: 100%
So that being said, can anyone help me with where the javascript would be added, and where the stylesheet is located I would use to enter the code to using the default theme.

Thanks a bunch.

New member

Posts

Joined
Sat Aug 24, 2019 11:57 pm

Post by eric47905 » Sat Aug 31, 2019 9:08 pm

Just checking back if anyone is able to help on this one? I am also pm’ing calimero to see if he has the solution.

New member

Posts

Joined
Sat Aug 24, 2019 11:57 pm

Post by duartemv » Fri Sep 20, 2019 5:13 pm

Looking to implement this also on 3.0.3.2.

Can any of you who knows how to do it, post a simple tutorial please?

Thank you!

Newbie

Posts

Joined
Wed Aug 07, 2019 5:56 pm

Post by FCWC » Sun Apr 19, 2020 4:32 am

This is not a good sign. Just found this in order to do same.
I PMed calimero1 but its been months since they have posted. So bumping to maybe get a reply to what when and where to make this work on 3.0.+

New member

Posts

Joined
Tue Jul 31, 2012 3:17 am

Post by straightlight » Sun Apr 19, 2020 4:53 am

From the first post, replace:

Code: Select all

<select>
with:

Code: Select all

<select name="filter[]" class="form-control">
Then, replace:

Code: Select all

$('input[name^=\'filter\']:checked').each(function(element) {
with:

Code: Select all

$('select[name^=\'filter\'] option:selected').each(function(element) {
Optional. Replace:

Code: Select all

id="{{ filter.filter_id }}" selected>
with:

Code: Select all

id="{{ filter.filter_id }}" selected="selected">
End of optional.

Then, follow this FAQ: viewtopic.php?f=134&t=215776#p718325 . This should resolved the issue.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 37 guests