Skip Navigation

[Resolved] Need Help Understanding URL Parameters in Views…

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

Problem:

Controlling the Views filter with URL arguments.

Solution:

It is possible to pass URL parameters to view, and filter the result, see our document:

Relevant Documentation:

https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/#controlling-the-filter-with-url-arguments

This support ticket is created 4 years, 11 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by GeneP3364 4 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1568723

Tell us what you are trying to do?
I have a view nested inside a content template. The view shows items related to the content in the template. Everything works fine with that.

I also have two custom select fields - 1) "activity" will determine "active" or "inactive" ... and 2) "location" will simply determine "local" or "remote".

I want to filter my view with these options using a URL...

This way I can have different links showing different output without having many views...
Something like:
website.com/content?activity=active&location=local
website.com/content?activity=active&location=remote
website.com/content?activity=inactive&location=local
website.com/content?activity=inactive&location=remote

Is there any documentation that you are following?
I have read and read documentation, but I'm not having any luck, and I think that's mainly because I'm not seeing examples of this.

I need to know exactly how to figure the view, and what the link should look like.

Is there a similar example that we can see?
Nope

What is the link to your site?
Not available at the moment

I'd definitely like to get help from Nigel again.

#1568939

Hello,

Yes, it is possible to pass URL parameters to view, and filter the result, see our document:
https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/#controlling-the-filter-with-url-arguments
Section "Controlling the filter with URL arguments"

If you are going to setup the filters on custom fields, please check this document too:
https://toolset.com/documentation/user-guides/views/filtering-views-by-custom-fields/
Section "Source for compare value":
URL parameter The value for the filter is set in the URL to the page This will let you create custom searches filters for Views, where visitors can control what the View will show.

#1569991

Right, I had read both of those... Like I said, I'm hoping to get more examples to see if I'm understanding the documentation. From what I've read, there's not much to it and I'm doing everything correctly. But let me make up an example and you can tell me if it's right...

1) Post Type "Property"
2) Post Type "Features"
3) "Features" Custom Field Group contains - Select Field with slug: buyer-type offering options - artist / butcher
4) One "Property" To Many "Features" Relationship Exists
5) Content Template for "Property" Contains View for "Features"
6) "Features" View Query Filter - Select posts in a Property Features relationship that are related to the current post in the loop
7) "Property" Post Named "Hannibal" Contains three related "Feature" Posts named "Gallery", "Paint Room", and "Killing Floor"
8) "Feature" Posts for "Gallery" and "Paint Room" have "buyer-type" selected as "artist" while "Killing Floor" has "buyer-type" selected as "butcher".

website.com/property/hannibal/?buyer-type=artist

This url should show the "Property" named "Hannibal" but not show the related "Feature" named "Killing Floor" as that is only for a "buyer-type" equal to "butcher" - correct?

Please let me know if I'm doing something wrong, because I'm trying to set up something exactly as this example states, and it's not working as intended. I'm getting all of the results.

#1570181

In the step 6) you mentioned above:
"Features" View Query Filter - Select posts in a Property Features relationship that are related to the current post in the loop

I don't see any custom field filter, you can follow the document I mentioned above to add a field filter:
Select items with field:
"buyer-type" is a string equal to URL_PARAM(buyer-type)

If you still need assitance for it, please provide a test site with the same problem, also point out the problem page URL and view URL, I can setup a demo for you. Private message box enabled.

#1571631

Your response led me to understand the solution... not the documentation.

I think it's worth creating a few examples with screenshots to hammer home certain points. Heck, now that I understand this I could write some examples for you in 5 mins that dummies like me could comprehend.