[#5348] Filtering a List with a Checkbox

8 years 10 months ago - 8 years 10 months ago #266208 by ernienet
I've had an ongoing problem with using a field as a filter in CB Lists. I had this working in the early days (CB 1.8+), but can't seem to get it to work in 2.0x.

I have a field called cb_nolist, which when checked indicates that the member does not want to be displayed on any list.

I then have several lists, one for each of several categories. So when someone registers, they can choose any number of categories to be listed under. This has always worked fine.

So when I use the filters tab in these lists and include cb_nolist and set it to anything at all - I've tried "not equal to 1", "less than 1", and several other variants, the list is returned empty.

To test it, if I set it to "equal to 1", or something else that would include those with cb_nolist and the site shows those people - so it works when it's true, but not when it's false.

I even changed the field to a drop-down with "TRUE" and "FALSE" options, and then changed the the filter in the list to "not equal to TRUE", and nothing.

Looking at the database, only three out of several hundred users have a value in the cb_nolist field - the rest are "NULL". This is because I hide the field from users - only the admin can set it.

Back in the olden days, I used SQL to set this (something like cb_nolist = 0 OR cb_nolist = NULL), and I know I can use it again in the Advanced view for the filter, but I was hoping to make this easier for my clients to manage on their own - they would not know SQL.

I'm assuming that the records that contain "NULL" in that field are somehow being excluded from the filter, and that's why the records don't show.

Either way, I just need this to work right.

Thanks,

Ernie

Please Log in to join the conversation.

8 years 10 months ago #266209 by ernienet
Replied by ernienet on topic Filtering a List with a Checkbox
I just tested using the Advanced filter with cb_nolist <1 OR cb_nolist is null, and it returns the desired results, but now the category in the Basic filter is no longer being recognized - so it's either one or the other and they can't be combined.

Please Log in to join the conversation.

8 years 10 months ago - 8 years 10 months ago #266221 by krileon
Replied by krileon on topic Filtering a List with a Checkbox
Checkbox fields are either 1 or 0. They are null if the users profile has never been saved (all fields begin as null) while the field is accessible. In your case Not Equal To 1 should work fine. Please ensure you're using latest CB 2.x nightly or CB 2.0.9.

I just tested using the Advanced filter with cb_nolist <1 OR cb_nolist is null, and it returns the desired results, but now the category in the Basic filter is no longer being recognized - so it's either one or the other and they can't be combined.

Correct, it's 1 or the other. You can not combine advanced and basic filtering rules. You'll have to manually add all the filters you're wanting to advanced.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

8 years 10 months ago #266240 by ernienet
Replied by ernienet on topic Filtering a List with a Checkbox
Using 2.0.9. Not Equal to 1 is not working in the Basic, even if it's the only filter. I had already checked the database comprofiler table and it's showing "null" for most records, 0 for one, and 2 for my record and another(that other one is a disabled account). There are 137 records.

When Not Equal to 1 is set for that field, no records are shown on the web site. When Equal to 1 is set, only my record is returned, as it should be.

My point is that it's not working as you describe or as expected.

The equivalent Advanced approach to the required settings for my list is:

cb_categories LIKE '%Associations%' and (cb_nolist is null OR cb_nolist = 0)

It would be a lot easier if I only had to have one List with a drop-down filter for the categories on the web site to filter by category, but I have to do this for all 15 categories individually.

Please Log in to join the conversation.

8 years 10 months ago #266243 by krileon
Replied by krileon on topic Filtering a List with a Checkbox

When Not Equal to 1 is set for that field, no records are shown on the web site. When Equal to 1 is set, only my record is returned, as it should be.

The filter is <>||ISNULL. Looks like the ISNULL isn't being handled by our userlist filters, which is why you're getting such odd results. Have added a bug ticket to fix.

forge.joomlapolis.com/issues/5348

It would be a lot easier if I only had to have one List with a drop-down filter for the categories on the web site to filter by category, but I have to do this for all 15 categories individually.

If your category field is a select field and it's set to be searchable on your userlist then it'll work exactly like that. They'll be able to select what category to filter the list by.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.198 seconds

Facebook Twitter LinkedIn