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.module

Add 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

peter feddo’s picture

Category: feature » bug

Do 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)

jhofer’s picture

This 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.)

defconjuan’s picture

good point. did you try it? i don't have time to see how that affects this but would love to know.

niek_kloots’s picture

http://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

jhofer’s picture

yes http://drupal.org/node/293894 did work for me for the record...

killes@www.drop.org’s picture

Status: Needs review » Closed (duplicate)