1

Currently running Drupal 7.61 with CiviCRM 5.7.2.

We have the "CiviCRM Upcoming" block enabled in our sidebar, however it continues to display events after their start date.

I've been fixing this by manually going into CiviCRM and disabling events which have passed, but ideally would like the Upcoming Events block to only display events which are actually upcoming (as I read it should here: https://wiki.civicrm.org/confluence/display/CRMDOC46/Event+Listings)

Thank you in advance!

Views export below (not sure if I've done this properly -- haven't done it before!)

$view = new view();
$view->name = 'civicrm_events';
$view->description = 'Calendar of CiviCRM Events';
$view->tag = 'civicrm';
$view->base_table = 'civicrm_event';
$view->human_name = 'CiviCRM Events';
$view->core = 7;
$view->api_version = '3.0';
$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 Calendar';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'view event info';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'calendar_style';
$handler->display->display_options['style_options']['name_size'] = '3';
$handler->display->display_options['style_options']['mini'] = '0';
$handler->display->display_options['style_options']['with_weekno'] = '0';
$handler->display->display_options['style_options']['multiday_theme'] = '1';
$handler->display->display_options['style_options']['theme_style'] = '1';
$handler->display->display_options['style_options']['max_items'] = '0';
$handler->display->display_options['row_plugin'] = 'civicrm_event_calendar';
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array(
  'article' => '#ffffff',
  'page' => '#ffffff',
);
/* Header: Global: Text area */
$handler->display->display_options['header']['area']['id'] = 'area';
$handler->display->display_options['header']['area']['table'] = 'views';
$handler->display->display_options['header']['area']['field'] = 'area';
$handler->display->display_options['header']['area']['label'] = 'Year Month Week Day';
$handler->display->display_options['header']['area']['content'] = '<table><tr><td><a href="/events/year/<?php print date(\'Y\'); ?>">This Year</a></td><td><a href="/events/month/<?php print date(\'Y-m\'); ?>">This Month</a></td><td><a href="/events/week/<?php print date(\'Y-m-d\'); ?>">This Week</a></td><td><a href="/events/day/<?php print date(\'Y-m-d\'); ?>">Today</a></td><td><a href="/upcoming">Full List</a></td></tr></table>';
$handler->display->display_options['header']['area']['format'] = 'php_code';
/* Footer: Global: Text area */
$handler->display->display_options['footer']['area']['id'] = 'area';
$handler->display->display_options['footer']['area']['table'] = 'views';
$handler->display->display_options['footer']['area']['field'] = 'area';
$handler->display->display_options['footer']['area']['label'] = 'More events';
$handler->display->display_options['footer']['area']['content'] = '<a href="/events/month/<?php print date(\'Y-m\'); ?>">More events</a>';
$handler->display->display_options['footer']['area']['format'] = 'php_code';
/* Field: CiviCRM Events: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'civicrm_event';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['hide_alter_empty'] = FALSE;
$handler->display->display_options['fields']['title']['link_to_civicrm_event'] = 'page';
/* Field: CiviCRM Events: Start Date */
$handler->display->display_options['fields']['start_date']['id'] = 'start_date';
$handler->display->display_options['fields']['start_date']['table'] = 'civicrm_event';
$handler->display->display_options['fields']['start_date']['field'] = 'start_date';
$handler->display->display_options['fields']['start_date']['label'] = '';
$handler->display->display_options['fields']['start_date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['start_date']['hide_alter_empty'] = FALSE;
$handler->display->display_options['fields']['start_date']['date_format'] = 'long';
/* Field: CiviCRM Address: City / Suburb */
$handler->display->display_options['fields']['city']['id'] = 'city';
$handler->display->display_options['fields']['city']['table'] = 'civicrm_address';
$handler->display->display_options['fields']['city']['field'] = 'city';
$handler->display->display_options['fields']['city']['label'] = '';
$handler->display->display_options['fields']['city']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['city']['location_type'] = '0';
$handler->display->display_options['fields']['city']['location_op'] = '0';
$handler->display->display_options['fields']['city']['is_primary'] = 0;
/* Sort criterion: CiviCRM Events: Start Date */
$handler->display->display_options['sorts']['start_date']['id'] = 'start_date';
$handler->display->display_options['sorts']['start_date']['table'] = 'civicrm_event';
$handler->display->display_options['sorts']['start_date']['field'] = 'start_date';
$handler->display->display_options['sorts']['start_date']['granularity'] = 'minute';
/* Contextual filter: CiviCRM Events: Start Date */
$handler->display->display_options['arguments']['start_date']['id'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['table'] = 'civicrm_event';
$handler->display->display_options['arguments']['start_date']['field'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['default_action'] = 'default';
$handler->display->display_options['arguments']['start_date']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['start_date']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['start_date']['granularity'] = 'year';
$handler->display->display_options['arguments']['start_date']['add_delta'] = 'yes';
$handler->display->display_options['arguments']['start_date']['date_fields'] = array(
  'civicrm_event.start_date' => 'civicrm_event.start_date',
);
/* Filter criterion: CiviCRM Events: Is Active */
$handler->display->display_options['filters']['is_active']['id'] = 'is_active';
$handler->display->display_options['filters']['is_active']['table'] = 'civicrm_event';
$handler->display->display_options['filters']['is_active']['field'] = 'is_active';
$handler->display->display_options['filters']['is_active']['value'] = '1';
$handler->display->display_options['filters']['is_active']['group'] = 0;
/* Filter criterion: CiviCRM Events: Is Public */
$handler->display->display_options['filters']['is_public']['id'] = 'is_public';
$handler->display->display_options['filters']['is_public']['table'] = 'civicrm_event';
$handler->display->display_options['filters']['is_public']['field'] = 'is_public';
$handler->display->display_options['filters']['is_public']['value'] = '1';
$handler->display->display_options['filters']['is_public']['group'] = 0;

/* Display: Month */
$handler = $view->new_display('page', 'Month', 'page');
$handler->display->display_options['display_description'] = 'Monthly calendar of events';
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'date_views_pager';
$handler->display->display_options['pager']['options']['date_id'] = 'month';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'calendar_style';
$handler->display->display_options['style_options']['name_size'] = '3';
$handler->display->display_options['style_options']['mini'] = '0';
$handler->display->display_options['style_options']['with_weekno'] = '0';
$handler->display->display_options['style_options']['multiday_theme'] = '1';
$handler->display->display_options['style_options']['theme_style'] = '1';
$handler->display->display_options['style_options']['max_items'] = '0';
$handler->display->display_options['style_options']['multiday_hidden'] = array(
  'start_date' => 'start_date',
  'city' => 'city',
);
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'civicrm_event_calendar';
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array(
  'article' => '#ffffff',
  'page' => '#ffffff',
);
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['footer'] = FALSE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: CiviCRM Events: Start Date */
$handler->display->display_options['arguments']['start_date']['id'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['table'] = 'civicrm_event';
$handler->display->display_options['arguments']['start_date']['field'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['default_action'] = 'default';
$handler->display->display_options['arguments']['start_date']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['start_date']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['start_date']['add_delta'] = 'yes';
$handler->display->display_options['arguments']['start_date']['date_fields'] = array(
  'civicrm_event.start_date' => 'civicrm_event.start_date',
);
$handler->display->display_options['path'] = 'events/month';

/* Display: Week */
$handler = $view->new_display('page', 'Week', 'page_1');
$handler->display->display_options['display_description'] = 'Weekly calendar of events';
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'date_views_pager';
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
$handler->display->display_options['pager']['options']['skip_empty_pages'] = 0;
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'calendar_style';
$handler->display->display_options['style_options']['calendar_type'] = 'week';
$handler->display->display_options['style_options']['name_size'] = '3';
$handler->display->display_options['style_options']['mini'] = '0';
$handler->display->display_options['style_options']['with_weekno'] = '0';
$handler->display->display_options['style_options']['multiday_theme'] = '1';
$handler->display->display_options['style_options']['theme_style'] = '1';
$handler->display->display_options['style_options']['max_items'] = '0';
$handler->display->display_options['style_options']['multiday_hidden'] = array(
  'start_date' => 'start_date',
  'city' => 'city',
);
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'civicrm_event_calendar';
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array(
  'article' => '#ffffff',
  'page' => '#ffffff',
);
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: CiviCRM Events: Start Date */
$handler->display->display_options['arguments']['start_date']['id'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['table'] = 'civicrm_event';
$handler->display->display_options['arguments']['start_date']['field'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['default_action'] = 'default';
$handler->display->display_options['arguments']['start_date']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['start_date']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['start_date']['granularity'] = 'week';
$handler->display->display_options['arguments']['start_date']['add_delta'] = 'yes';
$handler->display->display_options['arguments']['start_date']['date_fields'] = array(
  'civicrm_event.start_date' => 'civicrm_event.start_date',
);
$handler->display->display_options['path'] = 'events/week';
$handler->display->display_options['menu']['title'] = 'News & Events';
$handler->display->display_options['menu']['description'] = 'Events This Week';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['name'] = 'main-menu';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['menu']['context_only_inline'] = 0;

/* Display: Day */
$handler = $view->new_display('page', 'Day', 'page_2');
$handler->display->display_options['display_description'] = 'Daily calendar of events';
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'date_views_pager';
$handler->display->display_options['pager']['options']['skip_empty_pages'] = 0;
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'calendar_style';
$handler->display->display_options['style_options']['calendar_type'] = 'day';
$handler->display->display_options['style_options']['name_size'] = '3';
$handler->display->display_options['style_options']['mini'] = '0';
$handler->display->display_options['style_options']['with_weekno'] = '0';
$handler->display->display_options['style_options']['multiday_theme'] = '1';
$handler->display->display_options['style_options']['theme_style'] = '1';
$handler->display->display_options['style_options']['max_items'] = '0';
$handler->display->display_options['style_options']['groupby_times'] = 'half';
$handler->display->display_options['style_options']['multiday_hidden'] = array(
  'start_date' => 'start_date',
  'city' => 'city',
);
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'civicrm_event_calendar';
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array(
  'article' => '#ffffff',
  'page' => '#ffffff',
);
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: CiviCRM Events: Start Date */
$handler->display->display_options['arguments']['start_date']['id'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['table'] = 'civicrm_event';
$handler->display->display_options['arguments']['start_date']['field'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['default_action'] = 'default';
$handler->display->display_options['arguments']['start_date']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['start_date']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['start_date']['granularity'] = 'day';
$handler->display->display_options['arguments']['start_date']['add_delta'] = 'yes';
$handler->display->display_options['arguments']['start_date']['date_fields'] = array(
  'civicrm_event.start_date' => 'civicrm_event.start_date',
);
$handler->display->display_options['path'] = 'events/day';

/* Display: Year */
$handler = $view->new_display('page', 'Year', 'page_3');
$handler->display->display_options['display_description'] = 'Annual calendar of events';
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'date_views_pager';
$handler->display->display_options['pager']['options']['date_id'] = 'month';
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
$handler->display->display_options['pager']['options']['skip_empty_pages'] = 0;
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'calendar_style';
$handler->display->display_options['style_options']['calendar_type'] = 'year';
$handler->display->display_options['style_options']['name_size'] = '3';
$handler->display->display_options['style_options']['mini'] = '0';
$handler->display->display_options['style_options']['with_weekno'] = '0';
$handler->display->display_options['style_options']['multiday_theme'] = '1';
$handler->display->display_options['style_options']['theme_style'] = '1';
$handler->display->display_options['style_options']['max_items'] = '0';
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'civicrm_event_calendar';
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array(
  'article' => '#ffffff',
  'page' => '#ffffff',
);
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['footer'] = FALSE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: CiviCRM Events: Start Date */
$handler->display->display_options['arguments']['start_date']['id'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['table'] = 'civicrm_event';
$handler->display->display_options['arguments']['start_date']['field'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['default_action'] = 'default';
$handler->display->display_options['arguments']['start_date']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['start_date']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['start_date']['granularity'] = 'year';
$handler->display->display_options['arguments']['start_date']['add_delta'] = 'yes';
$handler->display->display_options['arguments']['start_date']['date_fields'] = array(
  'civicrm_event.start_date' => 'civicrm_event.start_date',
);
$handler->display->display_options['path'] = 'events/year';

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'calendar_style';
$handler->display->display_options['style_options']['name_size'] = '3';
$handler->display->display_options['style_options']['mini'] = '0';
$handler->display->display_options['style_options']['with_weekno'] = '0';
$handler->display->display_options['style_options']['multiday_theme'] = '1';
$handler->display->display_options['style_options']['theme_style'] = '1';
$handler->display->display_options['style_options']['max_items'] = '0';
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'civicrm_event_calendar';
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array(
  'article' => '#ffffff',
  'page' => '#ffffff',
);
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['footer'] = FALSE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: CiviCRM Events: Start Date */
$handler->display->display_options['arguments']['start_date']['id'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['table'] = 'civicrm_event';
$handler->display->display_options['arguments']['start_date']['field'] = 'start_date';
$handler->display->display_options['arguments']['start_date']['default_action'] = 'default';
$handler->display->display_options['arguments']['start_date']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['start_date']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['start_date']['add_delta'] = 'yes';
$handler->display->display_options['arguments']['start_date']['date_fields'] = array(
  'civicrm_event.start_date' => 'civicrm_event.start_date',
);

/* Display: Upcoming */
$handler = $view->new_display('block', 'Upcoming', 'block_2');
$handler->display->display_options['display_description'] = 'Upcoming Events';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'list';
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['header'] = FALSE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
$handler->display->display_options['block_description'] = 'CiviCRM Upcoming';
3

In the filter criteria of the view, add the filter - CiviCRM Events: End Date (>= now)

enter image description here

  • How do I get to this page? – josh Jan 10 at 0:34
  • I found it! Didnt look hard enough the first time. Thank you for this! – josh Jan 10 at 1:40
1

I ran into this on a Joomla site and may be related. For me, the online registration settings didn’t have an end/date time. Once I set this, these events no longer showed. Again, this was on a Joomla site (no sidebar) and may not be related.

  • This also happened on events which did not have online registration enabled – josh Jan 10 at 0:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.