Skip Navigation

[Resolved] multiple filters for relationships?

This thread is resolved. Here is a description of the problem and solution.

Problem:

I am having an issue where my "classes" view only supports one relationship filter, so when I add a filter for teacher (persons), the option to add a filter for course name becomes unavailable.

Solution:

I should restructure my view by applying the relationship filters in separate parts of the layout since Toolset Views currently supports only one relationship filter per view.

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.

This topic contains 1 reply, has 1 voice.

Last updated by charleneK 3 months, 1 week ago.

Assisted by: Christopher Amirian.

Author
Posts
#2800687
filters.png

I have a content type called "classes" it has relationships to two other content types called "courses" and "persons"

I have created a view called "calendar of classes" it has two nested views of "courses" and "teachers" so the output is something like this:

--Class
---persons name
---course name

I was wanting to be able to filer the "class" view by teacher name in the child view. I have set it up like this, and it works well:
[wpv-filter-start hide="false"]
[wpv-filter-controls]
[wpv-control-post-relationship ancestors="persons@class-persons.child" url_param="wpv-relationship1-filter"]
<div class="form-group">
<label for="wpv-relationship-filter">[wpml-string context="wpv-views"]person[/wpml-string]</label>
[wpv-control-post-ancestor type="checkboxes" ancestor_type="persons@class-persons.child"]
</div>
[/wpv-control-post-relationship]
[/wpv-filter-controls]
[wpv-filter-end]

The only quesiton is I also want to be able to add a filter by "course name as well" but the option to add another relationship filter is greyed out, why can't I add another? If I remove the "persons" relationship filter I can add "courses" filter, but I can't add them both, how to accomplish this?

as you can see once I add the "persons" post relationship post filter for one of the children the option goes grey without the ability to add the other.

thanks much for your help++

#2801022

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. This is a known limitation of the current Toolset Views filtering system. When you add a relationship filter (in your case, for the “persons” relationship), the interface reserves that filter slot and disables adding another relationship filter for a different relationship (like “courses”) on the same view.

Toolset Views currently supports only one relationship filter per view. The filtering system uses a single URL parameter and query modification process for relationship filters, so adding a second one isn’t supported out-of-the-box. This is why you can add either a persons filter or a courses filter, but not both simultaneously.

As an alternative solution consider restructuring your view so that each relationship filter is applied in a separate part of your layout. For example, you might filter the “classes” view by one relationship at the top level and then have nested views for the other relationship without adding an extra filter control to the same view.

Thanks

#2801188

Ok, thats what I was figuring, it's a limitation of toolset. thanks for your help. I'll look at different ways to accomplish what I need. thanks 🙂