Client wants to hide some published content from specific Views displays.
Unpublishing the content is not an option: it needs to remain accessible.
I added a boolean
exclude_from_view field to several content types.
I planned to add a boolean filter to exclude content from the necessary displays if this field's value was
TRUE, but I was surprised to find that when I did so, Views returned no results at all. Setting the boolean filter to
NOT FALSE had the same result.
This is happening because the field has been added to the existing content without a default value, so the field returns
NULL, which is neither
FALSE. (In PHP,
NULL is a "falsy" value, but apparently not to Views.)
A little research reveals that a lot of other people have complained about this problem.
Some of them think that boolean fields not set on entities should be considered
Others wish that
NULL fields could be treated as
Still others think that Views UI should offer filtering options for "Treat
FALSE" or "Treat
TRUE." (This is a cool idea but it requires patching core, which I'm not necessarily opposed to if it is the best way forward.)
What should I do?
Kudos to @no-sssweat for coming up with a viable workaround, which I upvoted below.
I'm still hoping for a better answer because I'm not satisfied with the user experience of the "checkboxes/radio buttons" field widget.
I think the client would really prefer a boolean checkbox, so I'm holding out for an answer that will give me that.