Skip Navigation

[Resolved] Filter by checkbox (yes, no, both)

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.

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

Problem: I would like to let my site visitors filter a View by date, using checkboxes "Past", "Future", and "All".

Solution: Toolset offers a date range filter, but the input fields represent start and end dates. You could use this date range filter to accomplish a similar task, or you could use multiple Views with Query Filters applied.

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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

Last updated by rieW 6 years ago.

Assisted by: Christian Cox.

Author
Posts
#626016

Hi

I am trying to build a site that lists webinars - both past and upcoming.

In my custom post type I have created a field called "webinar has been held".
If the webinar is upcoming, I will add a date and time in other fields, and if it has already been held I will check the "has been held" checkbox.

Now, in the search I want to show all webinars by default, but give the user the option to only see past webinars or only upcoming webinars.

But I'm a bit lost. How do I do this?
I think I know how to add a filter to check if the checkbox is checked or not - but I actually need three options: All, Future, Past.

How do I best do this?

This is probably completely basic, but I've only worked with Toolset for a few hours. ;o)
I have checked forum and Google but found nothing. So I hope you can help. :o)

Kind regards
Rie

#626029
Screen Shot 2018-03-18 at 5.36.00 PM.png

Hi, the easiest way to accomplish this type of filter is to use a "date" custom field and no checkbox. In your View of webinars, add a Filter Control that allows you to filter by a the custom date field. You will configure the filter to look for values between two numbers - a minimum date and maximum date. Please see the attached screenshot for an example.

The reason this is the easiest option is that Views does not provide text-based date filters like "All", or "Past", or "Future". Views does provide filters for date ranges, so your site Users can leave the date filters empty to see all webinars, or insert a start date of today to see future webinars, or insert an end date of today to see past webinars, or a combination of dates to see webinars in some other date range.

If you think two date fields will be difficult for your site Users to understand, we may be able to come up with another option if these are the only filters applied to the View. Let me know if that is the case, and we can discuss in more detail.

#626447

Hi Christian

Thanks for your fast reply! :o)

I don't think it would be optimal for users to have to choose or enter dates... I would like for them to simply click a button or check a checkbox.

A solution could be to have a button for "past webinars" that shows all posts with a date before current and a button for "future webinars" that shows all posts with a date after current. Would that be possible? Can the filter check for todays date - and just be a button in stead of a datepicker?

I would however need to also let the users search free text and choose categories. So I do need to add other filters...

If it is completely impossible, I will have to divide the content into "archive" and "future" and then add a search to each page for the other criteria...

Any good ideas? :o)

:o) Rie

#626690

I don't have a good solution that will allow you to use both text link filters like this and also use other search filters. That will require a significant amount of custom code that manipulates URL parameters. I think your idea of separating the results into multiple pages could be a good workaround. Create three similar pages that link to each other - one for all events, one for past, and one for future. The same View can be placed in each Page. The filter I described earlier can still work, but you will use shortcode options to pass the start or end date into the filter instead of datepicker filters shown to the users. Each page will show a list of posts filtered by the correct date range without requiring your users to select dates manually.

#626981

Ok, great - I'm almost there...! ;o)

One last question:
I used the archive page to show upcoming events, created a page for all events where users can do a search (not for future or past, but just for everything else - and then I added conditional content to show if it was old or not), and now I want a page to show all events where a certain checkbox is checked. (It's not enough that they are past a date; they have to have a checked checkbox).

But this page will eventually contain a lot of posts, so users will need to be able to do a search on this page.
How do I create a page that contains a custom search and ONLY the posts that have a checked checkbox? It seems I can either add filters or a search form - not both.

Am I missing something?

I really appreciate your help! :oD

:o) Rie

#627058

Hi again

I added a condition around the output - so if the box isn't checked, it skips to the next post without outputting data. ;o)

I think I'm good now. Thanks so much for your help!! :o)

And have a great day. :o)

:o) Rie

The forum ‘Types Community Support’ is closed to new topics and replies.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.