Skip Navigation

[Resolved] Show search results in 2 views

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
- - 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)

This topic contains 2 replies, has 2 voices.

Last updated by Beda 4 years, 11 months ago.

Assisted by: Beda.

Author
Posts
#1549839
CH - Search Health Condition.png

Tell us what you are trying to do?
I have set up a search called : Search by Health Condition
hidden link

When someone selects "Gastroenterology", the results show in the view below. But i would like to simultaneously add a view on the right side bar showing Diabetes results that have a "Featured" tag on it. Is this possible?

Is there any documentation that you are following?
No, i can't find any.

#1550519

Not if using AJAX, because this would only be possible when that other View would somehow listen to actual URL parameters when loading the page, which does not happen in your case since you use AJAX updated (without URL Update) search.

Another problem of course is, how do you tell that other view to load Featured Diabetes results, if the first view was queried by Gastroenterology?
What should happen if the First View was queried by "Refer a friend"?
This will not be possible to add just in the WordPress backend, it will very likely need some custom code because the Views queries cannot be conditional, they would listen to certain search terms passed, which cannot be translated to other terms either.

A possible approach, still not using AJAX Views, is to not use a View for the second "View" but instead, only a hardcoded content that is hidden or shown with an HTML Conditional that checks on the URL parameters of the first view
Or, you can eventually show/hide a whole View, if you need a list of posts.

HTML Conditional checking on the URL parameters can be built with these 2 ShortCodes:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-search-term

Something like this, for example, would show only if the View's URL parameter (search) are searching for "this" in "that" parameter:

[wpv-conditional if="( '[wpv-search-term param='that']' eq 'this' )"]
//Here, show anything that should be visible, when THAT was searched by THIS
[/wpv-conditional]

In your case, this could look like this:

[wpv-conditional if="( '[wpv-search-term param='wpv-condition']' eq 'Gastroenterology' )"]
//Here, show anything that should be visible, when THAT was searched by THIS
[/wpv-conditional]

However, this won't work with AJAX or when hiding the URLs in the search. You'd need to change that and reload the page, and show the URL when you perform a search

#1550521

Changing status, this message can be ignored.