Context:
- a date field with start date (required) and end date (optional)
- the content need to appear if the current date is between start date and end date OR if end date is empty
In the issue #874322: To Date & All Day Date Handling, which exposes another issue but related to current one, the fact that MySQL does not support NULL for datetime field is exposed. So the "empty" OR NULL filters cannot be used for the second clause (end date empty) because end date has the same value than start date.
So there should be a workaround there. I think some other people have been in the same trouble than me and may have found an elegant soution.
If not, a patch is required to handle such thing. There is 3 ways to offer such feature :
- Modify the EMPTY filter : the empty filter checks if the target field is the start date (value). If so, current process is kept. If target database column is value2 (the end date), an extra condition (OR) is added to the clause, to check if the start date is equal to the end date, according to the specified granularity.
- Create a new filter to compare 2 date fields together. But that would represent a big job, and it may duplicate the work in process in the Views module to allow field comparison.
- Create a separate filter specific to fields that end date enabled, with decicaded options (see first suggestion)
So let me know your thoughts, if there is not currently a correct workaround about such problem. I would be glad to help or provide a patch in the prefered way.
Comments
Comment #1
b-prod commentedAnother possibility just came to my mind.
I could be possible to add an additional column in the database for fields that use both start and end date. This value would be the state of the "use a different end date" checkbox.
I think this is more intuitive and will not conflict with other features, like "all day".
Comment #2
das-peter commentedI just posted a patch for the views filter handler provided by the date views module here: #1635810-3: Views filtering of optional end dates