I have a content type which has the following fields:
- month: List (integer) [jan, feb, ..., dec] (non mandatory)
- year: Date (only collects year - mandatory)
I can normally create two exposed views filters, one for the month and one for the year.
What I'd like to do though is have a single exposed filter which, internally, would operate on the two fields above at once.
For example if the operator is "Is Between" and the user selects Oct 2011
to Feb 2012
I'd like the filter to return only nodes which have:
- 2011, Oct
- 2011, Nov
- 2011, Dec
- 2012, NULL month
- 2012, Jan
- 2012, Feb
Note that I've used two fields (month and year) instead of one so I can have the possibility of a monthless node.
What approach should I take? I've thought of the following:
- use a third field which, on
hook_node_presave
will store the calculated (filter specific) date on the node. I wouldn't like this field to be visible on the edit node screen though - somehow (using a hook) calculate and rewrite the view filtering query. My problem here is how to display an exposed filter for a field which does not exist