Skip Navigation

[Resolved] Conditional Display of Search Filters

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

Problem: I have a custom search View with multiple filters. I am trying to show and hide some filters using CRED conditional groups, but it's not working.

Solution: CRED (or Forms) conditional groups cannot be used in a View's search filters. They can only be used in Forms. At this time there is not an easy way to show and hide some filters based on the selections in other filters.

Views has a feature called "Limiting Filter Inputs According to Available Results". When this configuration is chosen, the filters will respond intelligently each time a new filter is selected, so that only the filter options that would produce results are enabled. Unfortunately it is not as customizable as conditional HTML.

Relevant Documentation:
https://toolset.com/documentation/user-guides/front-page-filters/advanced-settings-custom-search/#dependent-parametric-search

0% of people find this useful.

This support ticket is created 6 years, 6 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#915845
Capture.PNG

So I am trying to create a filter search,

So If a category is chosen then some other fields are shown,

Then if a name chosen then other fields are shown

My form so far is:

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="form-group">
<label>[wpml-string context="wpv-views"]Categories[/wpml-string]</label>
[wpv-control-post-taxonomy taxonomy="category" type="select" url_param="wpv-category"]
</div>
<div class="form-group">
<label>[wpml-string context="wpv-views"]City[/wpml-string]</label>
[wpv-control-post-taxonomy taxonomy="cities" type="select" url_param="wpv-cities"]
</div>

<div class="form-group">
<label>[wpml-string context="wpv-views"]tag12[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-tag12" type="select" url_param="wpv-wpcf-tag12"]
</div>
[cred_show_group if="($(wpcf-tag12) eq 'ahsans')" mode="fade-slide"]

<div class="form-group">
<label>[wpml-string context="wpv-views"]tag3[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-tag3" url_param="wpv-wpcf-tag3"]
</div>

[/cred_show_group]
[cred_show_group if="($(wpcf-tag12) eq 'lucys')" mode="fade-slide"]

<div class="form-group">
<label>[wpml-string context="wpv-views"]tag3[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-tag5" url_param="wpv-wpcf-tag3"]
</div>

[/cred_show_group]
[cred_show_group if="($(category) eq 'cakes')" mode="fade-slide"]

<div class="form-group">
<label>[wpml-string context="wpv-views"]tag3[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-tag4" url_param="wpv-wpcf-tag3"]
</div>

[/cred_show_group]
[wpv-filter-end]

As you can see from the screen shot, Its not working at all 🙁

#915965

Hi, the first thing to note is that CRED/Forms shortcodes do not work in a View's Search and Pagination editor. CRED/Forms shortcodes only work in a Toolset Form. None of these cred_show_group shortcodes will have any effect here, and they should be removed.

The second thing to note is that there is not currently a way to respond to selected Filters using conditionals. View's conditional HTML features apply to the values in the current post, or the values in the current post in a View's loop. They do not apply to the filters currently selected in a View, which can be the source of some confusion.

The relevant feature we offer is in the Advanced Settings for Custom Search Views, and it's called "Limiting Filter Inputs According to Available Results". When this configuration is chosen, the filters will respond intelligently each time a new filter is selected, so that only the filter options that would produce results are enabled. Unfortunately it is not as customizable as conditional HTML. We have more information about this alternative here:
https://toolset.com/documentation/user-guides/front-page-filters/advanced-settings-custom-search/#dependent-parametric-search