Checkbox to filter results if a custom field is not blank
Hi Low,
I'm hoping to use Low Search on an event directory, so have bought a copy to test out. Looking good so far, but I've just came up against a query about how to use it.
Is it possible to have a checkbox custom field that when checked, would filter results by that custom field value being not blank?
I have a field named 'Open on Sunday,' and if this custom text field is blank, we assume the event is not taking place that day. If it's got a value in it (any value at all, other than blank - the value will be the opening times for the event in freeform text), then we assume the event is taking place that day.
So if a user doesn't check this checkbox, we'd like to see all results. But if they check this checkbox, we'd like the results to be filtered so that it only displays events that take place on a Friday (i.e. when this custom field is not blank).
I guess I'm trying to make this custom field behave similar to a category checkbox, but the reason it's a custom field is due to this data coming from a third party database in this format. Also, I have four such custom fields I want to use in the search form in this way.
I'm trying the following, but it's not working: http://pastie.org/4143608
So just wondered if you had any ideas on whether this is possible, and if so, how?
Thanks,
Stephen
Replies
Low 25 Jun 2012 08:33
So, it's basically like setting a search:custom_field="not IS_EMPTY" parameter, right?
You should be able to mimic that with a checkbox like so:
Stephen 25 Jun 2012 11:57
Hi Low,
That worked a treat, thanks. :)
(I noticed that GetSat added a space between the search: and cf_directory_opening_times_sun so I removed that to make it work as expected)
Thanks,
Stephen