Provide a handler for IS NULL/IS NOT NULL
| Project: | Views |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Views provides a number of useful out of the box handlers (=/!=, LIKE, etc). I didn't see a IS NULL/IS NOT NULL handler.
The following patch provides a new function views_handler_filter_null that allows filters to limit on IS NULL/IS NOT NULL. The operator passed in must be 'IS' or 'IS NOT'.
This patch does not add a operator handler to provide the IS/IS NOT array. An example might look like:
<?php
array('IS NOT' => t('Does'), 'IS' => t('Does not'))
?>This looks backwards, but it is correct as the completed phrases would be "Does" => IS NOT NULL and "Does not" => IS NULL.
If this patch is accepted, I promise to add a comment to the view developer handbook documenting it, such that it can be easily included in the main documentation.
The usecase for this functionality is the bio.module: filtering based on an author having crated a bio node or not.
| Attachment | Size |
|---|---|
| views_20070508_is_null_handler.patch | 1000 bytes |

#1
mfredrickson : on a semi-related note, I'd be interestind in having your opinion on http://drupal.org/node/101050 :
'Empty / not empty' filter for CCK fields (or more ?) - relevant comments are #2-#3, #8-#9, #20)
I'm not trying to hijack this thread, though (even if I'm probably spamming it :-) ). +1 on the ready to use handler.
#2
I think the link is topical. I commented in more detail over on that issue, but to paraphrase: this handler would be useful, if all CCK fields standardized on NULL as the empty indicator.
#3
Committed to -dev.
#4