I have created a new content type, let's call it NewsEvent. It represents both general notices and date-specific events.
It includes an optional CCK Date field.

I would like to create a View that includes:
-all Nodes of content type NewsEvent
-where the Date field is >= now
-OR where there is no date field

I also want to sort this so that the blank date items go first and the items that have dates come after.

The OR is what's getting me.

My current solution is to set all NewsEvents nodes that have blank dates as Sticky. Then I create a view like this:
Filter: Node Type isoneof NewsEvent
Sort: Node Sticky Descending
Date Descending

This comes close, but it doesn't exclude NewsEvents that have already occurred (those with a non-blank date in the past), and it also requires the site users to have permission to, and to remember to, set the Sticky flag on blank dated items.

Can Views do this or am I looking at code? If it's got to be code, a hint at the best approach would be really appreciated.

Thanks

Comments

frost’s picture

Found this: http://drupal.org/node/54457 which confirms you can't do ORs, at least through the UI.
But does that mean that it's just a UI issue and that the Views engine could handle it, if, for example, I inserted the SQL / code directly wherever it should go?

karens’s picture

Status: Active » Fixed

It could maybe be done using hook_views_query_alter() or a custom date field with its own custom query handler. You'd have to dig into the Views API and it is probably not so easy to do unless you're a Views guru.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

oligoelemento’s picture

I solved this issue modifying line 184 in date_views.inc:

Change:
$query->add_where(date_sql($type, $table .".". $table_field, $field_type, date_views_offset($field)) .' '. $filter['operator'] .' '. $date);

With:
$query->add_where(date_sql($type, $table .".". $table_field, $field_type, date_views_offset($field)) .' '. $filter['operator'] .' '. $date .' OR '. $table .'.'. $table_field .' IS NULL');

This allows listing the blank date items while using a date filter.