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:
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.
| Comment | File | Size | Author |
|---|---|---|---|
| views_20070508_is_null_handler.patch | 1000 bytes | mfredrickson |
Comments
Comment #1
yched commentedmfredrickson : 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.
Comment #2
mfredrickson commentedI 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.
Comment #3
merlinofchaos commentedCommitted to -dev.
Comment #4
(not verified) commentedComment #5
liquidcms commentedsorry to re-open.. but can someone point me to where this is visible? Is this just adding api that will need to still be coded/patched into other modules to be usable?
I have latest rev of Views and i don't see any way to filter on NULL for an integer field, also not on Title field - perhaps this was just added for Text fields?.
Comment #6
dawehnerIf you have a class which is a subclass of views_handler_filter_numeric you just have to define "allow empty" in your definitions.
Please don't reopen OLD issues