Skip Navigation

[Resolved] Parametric View displays all results when there is no parameter value

This support ticket is created 8 years, 1 month 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.

Our next available supporter will start replying to tickets in about 4.09 hours from now. Thank you for your understanding.

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 3 replies, has 2 voices.

Last updated by William U 8 years, 1 month ago.

Assigned support staff: Beda.

Author
Posts
#300384

I am trying to display parametric search results only when there is an actual parametric value.

I created a new parametric search view and placed the search button and the results view on separate pages so that I don't get an initial set of results on the search page. However, if I do not enter a search value and simply click 'Submit', i'm taken to the page with the results view with no URL parameter value to filter the results. Therefore all results are displayed.

I expected the results view to return no results since there was no value in the filtering parameter. Or, at least have the ability to set a default filter value that I could set to something that would never return a result.

I've seen this thread: https://toolset.com/forums/topic/stop-view-from-displaying-all-results-when-there-is-no-url-parameter-set/

Which resolves the problem of not having a parameter at all, but if the parameter exists and there is no value then results are still displayed.

Any help you can provide is certainly appreciated.

#300569

This seems currently not to be possible with the Views Parametric Search.

The parametric search will return "all results", if no value is passed in the search filtering parameters.

I need to consult with the 2nd Tier Support if any (in a close Future) feature is planned to be added to the Parametric Search options in Views.

Please await my updates here in the Forum by tomorrow Monday.

Thank you for your patience.

#300761

Unfortunately, it is not on our Roadmap to change the functionality of the Parametric search.
Parametric Search is restrictive, which means that it filters out posts not matching the search criteria.
If there is no search criteria, there is nothing to filter out.

You could try the same code as suggested here:
https://toolset.com/forums/topic/stop-view-from-displaying-all-results-when-there-is-no-url-parameter-set/
with this changes:
instead of:

isset($_GET['pi'])

use:

$_GET['pi'] != ''

of course, replacing

'pi'

with the correct URL parameter

Please note that this code worked because this specific client had one one URL parameter
If you have this same scenario, it would be useful to use that code.
If this is not the case, you would need to check any URL parameter related to the parametric search.

Unfortunately, as stated above this is not a feature of the Views Plugin, and it is not planned to implement this in future releases.
It means, the solution would always stay a "Custom Solution", which requires modifying the Plugin's files after each update.
I can unfortunately also be of restricted assistance only when it comes to custom coding or modifications in our Plugins Code.

Please let me know if you have further questions regarding the issue mentioned in this Thread
and let me know if the above solution works for you, I look forward to your reply!

Thank you

#301303

beda.s:

That code alteration actually worked perfectly. Thank you!