function date_field_views_data_alter in Date 7
Create a Views field for each date column we care about to supplement the generic 'entity_id' and 'revision_id' fields that are automatically created.
File
- date_views/
date_views.module, line 229
Code
function date_field_views_data_alter(&$result, $field, $module) {
if ($module == 'date') {
foreach ($result as $table => $data) {
$additional = array();
$field_name = $field['field_name'];
$key = array_key_exists('entity_id', $data) ? $field_name : $field_name . '-revision_id';
$field_name_data = $data[$key]['field'];
foreach ($data as $column => $value) {
if (array_key_exists('argument', $value)) {
$result[$table][$column]['argument']['handler'] = 'date_views_argument_handler';
// The following code would add a FIELDNAME_value and FIELDNAME_value2 field as well as the basic FIELDNAME field.
// Not sure yet if that is desirable.
//$result[$table][$column]['field'] = $field_name_data;
//$result[$table][$column]['field']['field'] = $value['argument']['field'];
//$result[$table][$column]['field']['add fields to query'] = TRUE;
}
if (array_key_exists('filter', $value)) {
$result[$table][$column]['filter']['handler'] = 'date_views_filter_handler';
}
// The old 'entity_id' and 'revision_id' values got rewritten in Views.
// The old values are still there with a 'moved to' key, so ignore them.
if (array_key_exists('field', $value) && !array_key_exists('moved to', $value['field'])) {
// Not sure yet if we still need a custom field handler in D7 now that custom formatters are available.
// Might still need it to handle grouping of multiple value dates.
//$result[$table][$column]['field']['handler'] = 'date_handler_field_date';
$result[$table][$column]['field']['add fields to query'] = TRUE;
}
}
}
}
}