Skip Navigation

[Resolved] How do I implement multiple Filters (in different locations) on the same View?

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Beda 5 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#1340269
Multiple-Filters.jpg

I have a standard Woocommerce setup on my TOOLSET site that sells Fishing Lures.

I have created a simple View on the home page that outputs a hierarchical list of the "Lure Type" taxonomy terms and links the visitor to an Archive page for that taxonomy ("Lure Type").

On the Archive page, I have set up a view to show all products that belong to that specific Lure Type Archive. Works fine.

So here is my issue....
The site started out as a simple site and I created an initial Filter to do some simple stuff like sort the products on the page by either Price or Name (ASC or DESC). I placed this filter directly above the product grouping.

However, the site has become a little more robust and I have ended up creating quite a few more needed Taxonomies for the products. These taxonomies include:
Bait Depth
Bait Brand
Bait Color
etc..

I want to be able to place a parametric search for these additional taxonomies in the left sidebar and have the results refresh automatically using AJAX when a filter changes. I am stumped as to how to create a secondary filter (parametric search) in a different location on the page and still keep the simple Name/Price filter in its current location (see screenshot).

Can this be done?

#1340345

It's difficult to determine what to do best here, I think I will need login and links + steps to what is happening where, or what should look how in what place.

Generally, you should not be using Views inside Archives, since Archives can and do have the exact same features, just they are already in an (archive) template, while with Views you can insert them wherever you like.

In any case, inserting an archive as your show is not possible because it depends - well, on the archive template and the archive you design in WordPress, it cannot be "inserted" somewhere.

On the other hand, a View can be inserted as you show, once only the filters, once the results.
This is even possible as a widget - but AJAX will not work on these cases.
https://toolset.com/documentation/getting-started-with-toolset/create-and-display-custom-lists-of-content/adding-views-as-widgets/

Can you eventually add access details or links to the issues and how it should look instead if wit above details the issue isn't clarified?

#1341071
Bait-Types-Admin.jpg

I am still unclear as to what you are saying. I am designing the Archive Page using Layouts. Sooo... I simply created a view and used the filter

Select posts with taxonomy:
Bait Types the same as the current archive page

to make sure that only those products that belong to that taxonomy will be displayed on the page.

It this case, the taxonomy that I am interested in displaying is "Bait Types". So when someone clicks on the "JawJacker 1.5 Squarebill" Bait Type, all of those products will be displayed.

I simply want to be able to manipulate the products that are displayed in 2 separate ways. I want a filter at the top of the product grid that allows the products to be displayed by either Price or Name (ASC). Then along the left sidebar, I want to be able to further refine the products that are displayed by selecting other taxonomy options (Product Brand, Bait Color, etc...) using checkboxes.

Hopefully the screenshots provided show you what I am trying to accomplish.

I can provide login information if you provide the secure credentials box.

#1341133
Filter-results-hidden.jpg

I think that I might have figured it out... however I would like your opinion to determine if this was the best solution.

What I did was this...
1) Created the View normally as before.
2) I created ALL of the potential filter options that I needed in that View (The top Name/Price filter as well as the filter for all of the other taxonomies)
3) I created special Class names around each designated filter area.
4) When I created the Archive Page layout, I added the View Results to the body content part of the page where I wanted the results to show
5) Then I also added the Search filter to the 2 locations where I wanted them to be displayed (Above the Product results and also in the sidebar)
6) Then I simply used the special CSS classes that I applied to each filter section to hide each filter that i didn't want displayed in that particular area... (display:none)

Seems to work great.

Does this make sense to you?

Any thoughts on how else it could be done?

#1341793

Wether or not you style the archives with Layouts, you will generally use Archives, not Views, and those are under Toolset > Archives.
In layouts, that's an Archive Cell.
A View is not used on archives, because an archive is basically already kind of a View, but restricted (by the code, not by Toolset), to the archive's main query object (posts, term, etc).

WordPress Archives, if made with Toolset, also support searches.

You can NOT split the search off the results, if you use a archive, that's right.
In the cases you need to split the search and the results only a View would help (with this feature you can display the search anywhere and results anywhere else).

You should generally not insert each of those elements twice.
What you can do is design your Search HTML so that it puts single inputs in different locations.
But inputting the same fitler twice just results in 2 identical filters be ing generated and of course, updating each other.

The way you achieved the goal is likely the only if you do not edit the HTML of the Filter section so to match the layout (which is not possilbe in this specific case, I see that)

It's however not best practice, you have now duplicated items on the template, in the HTML that is visible.
What you would need is the feature to build your search and results more freely, maybe GUteneberg (thhe beta Toolset Views) edit mode will help you in future, but right now, it's not possible to move around single items of a search like you require (unless you apply something similar to your solution)

In Gutenberg and Toolset Views' Beta right now you can edit already much more freely the filters, but such implementation still is not so easily possible as the filter still is as "one object" thing, rather than a "many objects" element that you can freely put on the template.

Please let me know if you need more details!
Thanks!