Commit 3edfe5ee authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-2796: adding year and/or month to event archive page title

parent 0081e98c
......@@ -253,6 +253,34 @@ function uw_ct_event_form_alter(&$form, &$form_state, $form_id) {
}
}
/**
* Implements hook_views_pre_render().
*
* Add the date to the title of the page.
*/
function uw_ct_event_views_pre_render(&$view) {
// If we are on a news archive page, change the title.
if ($view->name == 'events_responsive' && $view->current_display == 'events_archive_page') {
// Get the URL.
$args = arg();
// The date for the news archive will always be the last part of the URL.
$date = end($args);
// If we have the format YYYY-MM, change title.
// If we dont have that format it is just YYYY.
if (preg_match('/[0-9]{4}-[0-9]{1,2}/', $date)) {
$display_date = date("F Y", strtotime($date));
$view->build_info['title'] = 'Events - ' . $display_date;
}
else {
$view->build_info['title'] = 'Events - ' . $date;
}
}
}
/**
* Implements hook_views_pre_view().
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment