Closed (duplicate)
Project:
Event
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
7 Jun 2009 at 14:20 UTC
Updated:
28 Jun 2009 at 16:39 UTC
It seems to be by design that the Event module data fields are not exposed to Views. I, like countless other users, would like access to the Event End, Event Start, Has End Date, Has Time, and Timezone Name fields so here's the code for those who can't wait for this to be included into the module.
Step 1 - Update event.moduleAdd the following code to the VERY end of your event.module file:
function event_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'event') .'/includes',
);
}
Step 2 - Create event.views.inc
Create a file called event.views.inc and add the following code to it:
function event_views_data() {
$data = array();
$data['event']['table']['group'] = t('Events');
$data['event']['table']['join'] = array(
'node' => array (
'left_field' => 'nid',
'field' => 'nid',
),
);
$data['event']['event_start'] = array(
'title' => t('Event Start'),
'help' => t('This is the event start date.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
$data['event']['event_end'] = array(
'title' => t('Event End'),
'help' => t('This is the event end date.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
$data['event']['has_time'] = array(
'title' => t('Has Time'),
'help' => t('Boolean field.'),
'field' => array(
'handler' => 'views_handler_field_boolean',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_boolean_operator',
),
'argument' => array(
'handler' => 'views_handler_argument_numeric',
),
);
$data['event']['has_end_date'] = array(
'title' => t('Has End Date'),
'help' => t('Boolean field.'),
'field' => array(
'handler' => 'views_handler_field_boolean',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_boolean_operator',
),
'argument' => array(
'handler' => 'views_handler_argument_numeric',
),
);
$data['event_timezones']['table']['group'] = t('Events');
$data['event_timezones']['table']['join']['node'] = array(
'left_table' => 'event',
'left_field' => 'timezone',
'field' => 'timezone',
);
$data['event_timezones']['name'] = array(
'title' => t('Timezone Name'),
'help' => t('This is the timezone name for the event.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
return $data;
}
Comments
Comment #1
peter feddo commentedDo you mean for the filter handler to be set to:
'filter' => array(
'handler' => 'views_handler_filter_date',
instead of
'argument' => array(
'handler' => 'views_handler_argument_string',
so that views can have the proper date evaluation tools (ie. past events will be filtered out)
Comment #2
jhofer commentedThis is similar to: http://drupal.org/node/293894 but looks like you're including all fields (that patch only includes event end and event start fields into views.)
Comment #3
defconjuan commentedgood point. did you try it? i don't have time to see how that affects this but would love to know.
Comment #4
niek_kloots commentedhttp://drupal.org/node/293894#comment-1434610 works for me using Views 6.2.6 and Event 6.x-2.x-dev (2009-Jun-06).
To see it working look at http://openwaterswimming.eu/node/271
Comment #5
jhofer commentedyes http://drupal.org/node/293894 did work for me for the record...
Comment #6
killes@www.drop.org commentedsee #293894: Event Views: Views 2 support