Skip navigation.
Home

Events and Registration in Drupal 7

One of the more interesting experiences with Drupal version upgrades is the discovery that your favourite third party module is no longer available, or is not ready yet for a production service. This is particularly the case when you're not the person managing the upgrade process. Or better still, you are managing it now, because the first attempt wasn't managed, as such.

Such a discovery will be made with the old Drupal Event module; it was fine in Drupal 5, not so much in Drupal 6, and totally deserted in Drupal 7. So what can be done instead?

One path is to use node references, and Views to create a page with events and a list of attendees.

To begin install the content_access, nodereference_url, references, and eva (Entity Views Attachment) modules.

cd /usr/share/drupal7/sites/all/modules
wget http://ftp.drupal.org/files/projects/content_access-7.x-1.2-beta1.tar.gz
wget http://ftp.drupal.org/files/projects/nodereference_url-7.x-1.12.tar.gz
wget http://ftp.drupal.org/files/projects/references-7.x-2.0.tar.gz
wget http://ftp.drupal.org/files/projects/eva-7.x-1.1.tar.gz
tar xvf content_access-7.x-1.2-beta1.tar.gz
tar xvf eva-7.x-1.1.tar.gz
tar xvf nodereference_url-7.x-1.12.tar.gz
tar xvf references-7.x-2.0.tar.gz

Enable the modules and create two content types; Registration and Events (Structure - Content Types).
Go to content types - registration - manage fields. With Registration ensure that you have the fields that you want for registration and nothing else (e.g., Name, Email, Institution)

Add new field "Event" label, "field_node_reference_event" name, "Node Reference" as node module element, "Reference from URL" text field.

Under field settings, the content type that can be referenced is "Event". Use "user select list" for Fallback behaviour. Make this a required field.

Allow for referenceable node links on full view of the node and teaser view. Link title can be "Sign Up", or "Register for this event", "RSVP", or whatever is appropriate. Hover title can give additional instructions (e.g., "Please provide email and name"). Select "The Referenced Node" as the URL path.

Optionally change the Registration access control so that non-anonymous visitors cannot view those who have registered, and spammers can't screen-scrape their email, etc.

Create an event of some description (e.g., Advanced Pascal Programming course), and when a visitor goes to said page, they will be able to select a registration link.

... unless! In the past you've removed the content links from the template, like I had. Now you'll have to make them just a little bit more specific.


vim /usr/share/drupal7/sites/all/themes/$theme547/template.php
- $vars['content']['links'] = FALSE;
+ if(drupal_is_front_page()) $vars['content']['links'] = FALSE;

Create a view to generate a list of all the people who have registered. The View name can be something like "Event Registrations".

Filter content type according to Content Type, Registrations. Add Entity Content to the View. Select "Advanced", "Entity content" (node), Bundles (Event), Arguments (Use the ID of the entity the view is attached to).

Add a context filter, based on fields, pick Fields:Event (node_reference_event) - nid. When the filter is not in URL, select Default and provide Content ID from URL.

Adopt whichever formatting option is best for you (e.g., table). Add the Field, Context Email.

Flush cache http://example.com/admin/config/development/performance

The View should look like this (you can import it!)

$view = new view;
$view->name = 'event_registrations';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Event Registrations';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Event Registrations';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Content: Email */
$handler->display->display_options['fields']['field_email']['id'] = 'field_email';
$handler->display->display_options['fields']['field_email']['table'] = 'field_data_field_email';
$handler->display->display_options['fields']['field_email']['field'] = 'field_email';
$handler->display->display_options['fields']['field_email']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_email']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_email']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_email']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_email']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_email']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_email']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_email']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_email']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_email']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_email']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_email']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_email']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_email']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_email']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_email']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_email']['field_api_classes'] = 0;
/* Field: Content: Institution */
$handler->display->display_options['fields']['field_institution']['id'] = 'field_institution';
$handler->display->display_options['fields']['field_institution']['table'] = 'field_data_field_institution';
$handler->display->display_options['fields']['field_institution']['field'] = 'field_institution';
$handler->display->display_options['fields']['field_institution']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_institution']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_institution']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_institution']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_institution']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_institution']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_institution']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_institution']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_institution']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_institution']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_institution']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_institution']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_institution']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_institution']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_institution']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_institution']['field_api_classes'] = 0;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Fields: Event (field_node_reference_event) - nid */
$handler->display->display_options['arguments']['field_node_reference_event_nid']['id'] = 'field_node_reference_event_nid';
$handler->display->display_options['arguments']['field_node_reference_event_nid']['table'] = 'field_data_field_node_reference_event';
$handler->display->display_options['arguments']['field_node_reference_event_nid']['field'] = 'field_node_reference_event_nid';
$handler->display->display_options['arguments']['field_node_reference_event_nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['field_node_reference_event_nid']['default_argument_type'] = 'user';
$handler->display->display_options['arguments']['field_node_reference_event_nid']['default_argument_options']['user'] = FALSE;
$handler->display->display_options['arguments']['field_node_reference_event_nid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['field_node_reference_event_nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['field_node_reference_event_nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['field_node_reference_event_nid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['field_node_reference_event_nid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['field_node_reference_event_nid']['not'] = 0;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = '1';
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator_id'] = '';
$handler->display->display_options['filters']['status']['expose']['label'] = 'Published';
$handler->display->display_options['filters']['status']['expose']['use_operator'] = FALSE;
$handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op';
$handler->display->display_options['filters']['status']['expose']['identifier'] = 'status';
$handler->display->display_options['filters']['status']['expose']['required'] = TRUE;
$handler->display->display_options['filters']['status']['expose']['remember'] = FALSE;
$handler->display->display_options['filters']['status']['expose']['multiple'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'registration' => 'registration',
);
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'event-registrations';

/* Display: Entity content */
$handler = $view->new_display('entity_view', 'Entity content', 'entity_view_1');
$handler->display->display_options['entity_type'] = 'node';
$handler->display->display_options['bundles'] = array(
  0 => 'event',
);
$translatables['event_registrations'] = array(
  t('Master'),
  t('Event Registrations'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('Email'),
  t('Institution'),
  t('All'),
  t('Published'),
  t('Page'),
  t('Entity content'),
);