Skip Navigation

[Resolved] Conditional statement in filter for checkboxes not working

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

Problem: I have a custom search View that includes several checkbox filters grouped under the heading "Select Features". I have activated the "Only show available inputs" option and I'm using AJAX updates. When no checkbox filters are available, this section becomes empty. I would like to remove the heading when no checkboxes are shown.

Solution: There is no built-in way to connect a filter heading with the filters grouped underneath it, but you could use custom JS and CSS to manipulate the DOM as needed. The Frontend Events button in your Filter Editor's JS panel will produce a template you can use to tap into filter changes or pagination events. Use "jQuery" instead of "$" in these callbacks for best results.

This support ticket is created 6 years, 9 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 3 replies, has 2 voices.

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

Assisted by: Christian Cox.

Author
Posts
#681262
Screen Shot 2018-04-17 at 11.58.00 AM.png

I am trying to: Hide the title of features with no data. The features are check-boxes

Here is the code:

[wpv-conditional if="( $(wpcf-profile-items) ne '0' )" ]
<br><h4>[wpml-string context="wpv-views"]Select Features[/wpml-string]</h4>
[/wpv-conditional]

I've tried a few variations for the not equal value but the

hidden link

I expected to see: When changing the location to a property with no features (like -Unique Alternatives) the title would not be displayed

Instead, I got: the title displays

#681394

Hi, the conditional syntax you mentioned is intended for use in the context of a single post, not in the context of the filters selected or available in a custom search View. I'm afraid there's not a built-in way to accomplish what you're looking for. It would require some custom CSS and possibly JavaScript that hides each title element if no filters are available. We do offer frontend search filter event hooks where you can add your own scripts. Edit this View in wp-admin and find the JS panel underneath the Filter Editor. Toggle that open and you will find a button that allows you to insert some JavaScript template code where you can hook in to specific custom search or pagination events. The CSS panel is also available for you to add custom CSS code if needed.

#687657

Thanks Christian, that's a good work around.

Mike

#687732

OK great. FYI you should probably use the namespace "jQuery" instead of "$" in these callbacks. Feel free to reopen if you have questions about that.