Is it possible to create a CCK field which holds a Date (or Date and Time) and which integrates with Views such that the Views Date Filter will work correctly?
I can create a CCK field of type "datetime", which accepts an input and stores it in the database correctly (as far as I can see). However when I access it through Views, the date filter is invoked, but fails to operate correctly, and the date always displays as 01/01/1970 12:23am. I think Views is failing to read my database field correctly (or at all).
I have tried using "date" and "timestamp" fields, but I get SQL errors at the point where CCK is trying to create the table to put them into.
My code looks something like the following:
/**
* Implementation of cck hook_field_settings()
*/
function my_field_field_settings($op, $field) {
switch ($op) {
case 'form':
...
case 'validate':
...
case 'save':
...
case 'database columns':
$columns = array('value' => array());
$columns['value']['type'] = $field['data_type'] ;
$columns['value']['not NULL'] = TRUE;
$columns['value']['sortable'] = TRUE;
return $columns;
case 'filters':
return array(
'default' => array(
'name' => t('Default'),
'operator' => 'views_handler_operator_gtlt',
),
);
case 'callbacks':
return array(
'view' => CONTENT_CALLBACK_CUSTOM,
);
case 'views data':
$data = content_views_field_views_data($field);
$table_alias = content_views_tablename($field);
$data[$table_alias][$field['field_name'] .'_value']['field']['handler'] = 'views_handler_field_date';
$data[$table_alias][$field['field_name'] .'_value']['sort']['handler'] = 'views_handler_sort_date';
$data[$table_alias][$field['field_name'] .'_value']['filter']['handler'] = 'views_handler_filter_date';
return $data;
}
}
Is there something else I should be doing? Or is this just not possible?
Is there an example somewhere to copy?
With thanks,
Tony
Fixed
2.1
Views Integration
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.