Skip Navigation

[Resolved] Conditional display of reset filters button

This support ticket is created 5 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
- - 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)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Beda 5 years, 6 months ago.

Assisted by: Beda.

Author
Posts
#1364503

Tell us what you are trying to do?
Hi! I have a grid of posts which are searchable with a search bar and filter. I'd like to include the reset filter button only when search results or a filtered view is being displayed, I was wondering if there is some jquery which could help?

Thanks!

#1364569

I don't think there is jQuery required for this (and we could not help with such custom code here neither).

Instead it should be possible to wrap the reset button (or any other item in the View you want to show conditionally) into a so called "HTML Condition".
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

Basically you would listen to (any) search parameter, and if not empty, display the reset button.
Since you never will know what precise parameter will be used, I suggest to check upon the URL queries that always are there in a View:
wpv_filter_submit or wpv_view_count

So your condition could look like this:

[wpv-conditional if="( '[wpv-search-term param="wpv_filter_submit"]' ne '' )"][wpv-filter-reset output="bootstrap"][/wpv-conditional]

I have set this up using the Toolset Guided User Interface, first inserting the [wpv-filter-reset output="bootstrap"], then wrapping that in a conditional output, and editing this later to insert the [wpv-search-term param="wpv_filter_submit"] listener

That will now display my reset button only if I actually searched by something (no matter what) in the View (pressed submit button, basically), because only then the wpv_filter_submit or wpv_view_count are present in the URL.

Does that help to reach your goal?