Add custom upcoming events block to group page

Override the commons upcoming events view, and add custom template to
display upcoming event details.

Change-Id: Id82d92c60fa7aee22fc747a151e680c8bf9ddcaa
This commit is contained in:
Marton Kiss 2014-10-31 21:54:46 +01:00
parent 4088f0d906
commit 55e58897f7
10 changed files with 455 additions and 1 deletions

View File

@ -153,5 +153,6 @@ dependencies[] = groups_homepage
dependencies[] = groups_common
dependencies[] = groups_auth
dependencies[] = groups_feeds
dependencies[] = groups_events
dependencies[] = groups_events_pages
dependencies[] = groups_pages

View File

@ -171,6 +171,16 @@ function groups_update_7106() {
groups_update_7104();
}
/**
* Enable groups_events module.
*/
function groups_update_7107() {
if (!module_exists('groups_events')) {
module_enable(array('groups_events'));
drupal_flush_all_caches();
}
}
/**
* Add markdown filter with permissions.
*/

View File

@ -0,0 +1,12 @@
<?php
/**
* @file
* groups_events.features.inc
*/
/**
* Implements hook_views_api().
*/
function groups_events_views_api($module = NULL, $api = NULL) {
return array("api" => "3.0");
}

View File

@ -0,0 +1,13 @@
name = Groups Events
description = Groups events building blocks
core = 7.x
package = Groups - Building Blocks
version = 7.x-1.0
project = groups_events
dependencies[] = views
dependencies[] = views_content
dependencies[] = views_load_more
features[ctools][] = views:views_default:3.0
features[features_api][] = api:2
features[views_view][] = groups_events_upcoming_events
features_exclude[dependencies][ctools] = ctools

View File

@ -0,0 +1,7 @@
<?php
/**
* @file
* Code for the Groups Events feature.
*/
include_once 'groups_events.features.inc';

View File

@ -0,0 +1,263 @@
<?php
/**
* @file
* groups_events.views_default.inc
*/
/**
* Implements hook_views_default_views().
*/
function groups_events_views_default_views() {
$export = array();
$view = new view();
$view->name = 'groups_events_upcoming_events';
$view->description = 'Display upcoming events site-wide, or per-group.';
$view->tag = 'commons_events';
$view->base_table = 'node';
$view->human_name = 'Groups Events - Upcoming 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'] = 'Events';
$handler->display->display_options['use_more_always'] = FALSE;
$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'] = 'load_more';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Title */
$handler->display->display_options['fields']['title_field']['id'] = 'title_field';
$handler->display->display_options['fields']['title_field']['table'] = 'field_data_title_field';
$handler->display->display_options['fields']['title_field']['field'] = 'title_field';
$handler->display->display_options['fields']['title_field']['label'] = '';
$handler->display->display_options['fields']['title_field']['link_to_entity'] = 1;
/* Field: Content: Date */
$handler->display->display_options['fields']['field_date']['id'] = 'field_date';
$handler->display->display_options['fields']['field_date']['table'] = 'field_data_field_date';
$handler->display->display_options['fields']['field_date']['field'] = 'field_date';
$handler->display->display_options['fields']['field_date']['label'] = '';
$handler->display->display_options['fields']['field_date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_date']['settings'] = array(
'format_type' => 'event_datetime',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
);
/* Field: Registration Settings: Spaces used */
$handler->display->display_options['fields']['capacity_used']['id'] = 'capacity_used';
$handler->display->display_options['fields']['capacity_used']['table'] = 'node';
$handler->display->display_options['fields']['capacity_used']['field'] = 'capacity_used';
$handler->display->display_options['fields']['capacity_used']['label'] = '';
$handler->display->display_options['fields']['capacity_used']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['capacity_used']['separator'] = '';
$handler->display->display_options['fields']['capacity_used']['suffix'] = ' attendees';
/* Field: Content: Comment count */
$handler->display->display_options['fields']['comment_count']['id'] = 'comment_count';
$handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics';
$handler->display->display_options['fields']['comment_count']['field'] = 'comment_count';
$handler->display->display_options['fields']['comment_count']['label'] = '';
$handler->display->display_options['fields']['comment_count']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['comment_count']['alter']['text'] = '[comment_count] comments';
$handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE;
/* Sort criterion: Content: Date - start date (field_date) */
$handler->display->display_options['sorts']['field_date_value']['id'] = 'field_date_value';
$handler->display->display_options['sorts']['field_date_value']['table'] = 'field_data_field_date';
$handler->display->display_options['sorts']['field_date_value']['field'] = 'field_date_value';
/* 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'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = 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(
'event' => 'event',
);
/* Filter criterion: Content: Date - start date (field_date) */
$handler->display->display_options['filters']['field_date_value']['id'] = 'field_date_value';
$handler->display->display_options['filters']['field_date_value']['table'] = 'field_data_field_date';
$handler->display->display_options['filters']['field_date_value']['field'] = 'field_date_value';
$handler->display->display_options['filters']['field_date_value']['operator'] = '>=';
$handler->display->display_options['filters']['field_date_value']['form_type'] = 'date_text';
$handler->display->display_options['filters']['field_date_value']['default_date'] = 'now';
/* Display: Feed */
$handler = $view->new_display('feed', 'Feed', 'feed');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['style_plugin'] = 'rss';
$handler->display->display_options['row_plugin'] = 'node_rss';
$handler->display->display_options['path'] = 'events-upcoming.xml';
$handler->display->display_options['displays'] = array(
'default' => 'default',
'page' => 'page',
);
/* Display: Global Block */
$handler = $view->new_display('block', 'Global Block', 'commons_events_upcoming_global_block');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Upcoming events';
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'default';
$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;
/* Display: Group pane */
$handler = $view->new_display('panel_pane', 'Group pane', 'panel_pane_1');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Upcoming events';
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'load_more';
$handler->display->display_options['pager']['options']['items_per_page'] = '3';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'default';
$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['row_options']['inline'] = array(
'capacity_used' => 'capacity_used',
'comment_count' => 'comment_count',
);
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: OG membership: OG membership from Node */
$handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel';
$handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node';
$handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel';
$handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE;
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Content: Title */
$handler->display->display_options['fields']['title_field']['id'] = 'title_field';
$handler->display->display_options['fields']['title_field']['table'] = 'field_data_title_field';
$handler->display->display_options['fields']['title_field']['field'] = 'title_field';
$handler->display->display_options['fields']['title_field']['label'] = '';
$handler->display->display_options['fields']['title_field']['link_to_entity'] = 1;
/* Field: Content: Date */
$handler->display->display_options['fields']['field_date']['id'] = 'field_date';
$handler->display->display_options['fields']['field_date']['table'] = 'field_data_field_date';
$handler->display->display_options['fields']['field_date']['field'] = 'field_date';
$handler->display->display_options['fields']['field_date']['label'] = '';
$handler->display->display_options['fields']['field_date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_date']['settings'] = array(
'format_type' => 'event_datetime',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
);
/* Field: Registration Settings: Spaces used */
$handler->display->display_options['fields']['capacity_used']['id'] = 'capacity_used';
$handler->display->display_options['fields']['capacity_used']['table'] = 'node';
$handler->display->display_options['fields']['capacity_used']['field'] = 'capacity_used';
$handler->display->display_options['fields']['capacity_used']['label'] = '';
$handler->display->display_options['fields']['capacity_used']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['capacity_used']['separator'] = '';
$handler->display->display_options['fields']['capacity_used']['suffix'] = ' attendees,';
/* Field: Content: Comment count */
$handler->display->display_options['fields']['comment_count']['id'] = 'comment_count';
$handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics';
$handler->display->display_options['fields']['comment_count']['field'] = 'comment_count';
$handler->display->display_options['fields']['comment_count']['label'] = '';
$handler->display->display_options['fields']['comment_count']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['comment_count']['alter']['text'] = '[comment_count] comments';
$handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE;
/* Field: Content: Body */
$handler->display->display_options['fields']['body']['id'] = 'body';
$handler->display->display_options['fields']['body']['table'] = 'field_data_body';
$handler->display->display_options['fields']['body']['field'] = 'body';
$handler->display->display_options['fields']['body']['label'] = '';
$handler->display->display_options['fields']['body']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['body']['type'] = 'text_summary_or_trimmed';
$handler->display->display_options['fields']['body']['settings'] = array(
'trim_length' => '600',
);
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: OG membership: Group ID */
$handler->display->display_options['arguments']['gid']['id'] = 'gid';
$handler->display->display_options['arguments']['gid']['table'] = 'og_membership';
$handler->display->display_options['arguments']['gid']['field'] = 'gid';
$handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel';
$handler->display->display_options['arguments']['gid']['default_action'] = 'empty';
$handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['pane_category']['name'] = 'Commons';
$handler->display->display_options['pane_category']['weight'] = '0';
$handler->display->display_options['argument_input'] = array(
'gid' => array(
'type' => 'context',
'context' => 'entity:node.nid',
'context_optional' => 0,
'panel' => '0',
'fixed' => '',
'label' => 'OG membership: Group ID',
),
);
/* Display: Landing Page pane */
$handler = $view->new_display('panel_pane', 'Landing Page pane', 'panel_pane_2');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['exposed_form'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['expose_sort_order'] = FALSE;
$handler->display->display_options['exposed_form']['options']['autosubmit'] = TRUE;
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'node';
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['header'] = FALSE;
$handler->display->display_options['defaults']['empty'] = FALSE;
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'No events have been created yet.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
$handler->display->display_options['defaults']['sorts'] = FALSE;
/* Sort criterion: Content: Promoted to front page */
$handler->display->display_options['sorts']['promote']['id'] = 'promote';
$handler->display->display_options['sorts']['promote']['table'] = 'node';
$handler->display->display_options['sorts']['promote']['field'] = 'promote';
$handler->display->display_options['sorts']['promote']['exposed'] = TRUE;
$handler->display->display_options['sorts']['promote']['expose']['label'] = 'Featured';
/* Sort criterion: Content: Date - start date (field_date) */
$handler->display->display_options['sorts']['field_date_value']['id'] = 'field_date_value';
$handler->display->display_options['sorts']['field_date_value']['table'] = 'field_data_field_date';
$handler->display->display_options['sorts']['field_date_value']['field'] = 'field_date_value';
$handler->display->display_options['sorts']['field_date_value']['exposed'] = TRUE;
$handler->display->display_options['sorts']['field_date_value']['expose']['label'] = 'Date';
$handler->display->display_options['inherit_panels_path'] = '1';
$export['groups_events_upcoming_events'] = $view;
return $export;
}

View File

@ -10,6 +10,7 @@ dependencies[] = menu
dependencies[] = page_manager
dependencies[] = panels_mini
dependencies[] = strongarm
dependencies[] = groups_events
features[ctools][] = ds:ds:1
features[ctools][] = page_manager:pages_default:1
features[ctools][] = panels_mini:panels_default:1

View File

@ -105,6 +105,29 @@ function groups_pages_panelizer_defaults() {
$display->content['new-4D07DA83-5650-4EE6-AA34-DEBDE8467ADB'] = $pane;
$display->panels['two_66_33_first'][1] = 'new-4D07DA83-5650-4EE6-AA34-DEBDE8467ADB';
$pane = new stdClass();
$pane->pid = 'new-54C2DF39-C222-48D2-A1E6-31E4C9D18B4F';
$pane->panel = 'two_66_33_first';
$pane->type = 'views_panes';
$pane->subtype = 'groups_events_upcoming_events-panel_pane_1';
$pane->shown = TRUE;
$pane->access = array();
$pane->configuration = array(
'context' => array(
0 => 'panelizer',
),
);
$pane->cache = array();
$pane->style = array(
'settings' => NULL,
);
$pane->css = array();
$pane->extras = array();
$pane->position = 2;
$pane->locks = array();
$pane->uuid = '54C2DF39-C222-48D2-A1E6-31E4C9D18B4F';
$display->content['new-54C2DF39-C222-48D2-A1E6-31E4C9D18B4F'] = $pane;
$display->panels['two_66_33_first'][2] = 'new-54C2DF39-C222-48D2-A1E6-31E4C9D18B4F';
$pane = new stdClass();
$pane->pid = 'new-0702E7C9-CCB9-4EA3-B2C5-7D1ACDF55BD5';
$pane->panel = 'two_66_33_second';
$pane->type = 'entity_field';

View File

@ -137,7 +137,8 @@
/* === Upcoming events block === */
.view-id-commons_events_upcoming {
.view-id-commons_events_upcoming,
.view-commons-events-upcoming {
// Hide sort filter and event count
.attachment-before,
.view-filters {
@ -147,21 +148,27 @@
padding: 15px 0px;
border-bottom: 1px solid #EBEFF4;
}
.views-row-last {
border-bottom: 0px;
}
.views-row:hover {
}
.views-row-first {
padding-top: 0px;
}
.views-field-title-field,
h3 {
margin: 0px;
padding: 0px;
}
.views-field-title-field a,
h3 > a {
color: #000;
font-size: 14px;
font-weight: 600;
}
.views-field-field-date,
.field-type-datetime {
color: #DA422F;
font-size: 10px;
@ -170,6 +177,15 @@
color: #333;
font-style: italic;
}
.views-field-comment-count,
.views-field-capacity-used {
padding-top: 5px;
color: #8A959E;
font-size: 12px;
}
.more-link {
display: none;
}
}
/** Activity stream **/
@ -224,6 +240,16 @@
.page-node {
h2.pane-title {
color: #2A4E68;
margin-bottom: 25px;
}
.pane-groups-events-upcoming-events-panel-pane-1 h2.pane-title {
display: inline-block;
line-height: 16px;
font-size: 80%;
text-transform: uppercase;
}
.region-two-66-33-second h2.pane-title {
color: #2A4E68;
font-weight: 300;
font-size: 18px;
@ -240,6 +266,7 @@
}
}
.pane-node-field-resource-links {
@extend .clearfix;
border-top: 1px dotted #C5E2EA;
margin-top: 25px;
padding-top: 25px;
@ -267,6 +294,10 @@
font-size: 10px;
}
}
.pane-groups-events-upcoming-events-panel-pane-1 {
border-top: 1px dotted #C5E2EA;
margin-top: 25px;
}
}
.view-profile-badges {
@ -288,6 +319,63 @@
}
}
/* === Event large teaser === */
.event--large-teaser {
@extend .clearfix;
.container-first {
float: left;
width: 60%;
}
.container-second {
float: left;
width: 40%;
}
h3 {
margin-bottom: 5px;
}
h3 a {
color: #30739C;
font-weight: 400;
font-size: 24px;
}
.field-name-field-address {
margin-bottom: 10px;
}
.field-body {
color: #888;
line-height: 1.4;
font-size: 16px;
padding-bottom: 10px;
}
.field-date {
font-size: 18px;
color: #000;
font-weight: 300;
.date-part {
font-weight: 400;
font-size: 18px;
}
.date-display-start {
}
.date-display-end {
}
}
.field-name-field-organizers .field-label {
font-weight: 400;
font-size: 12px;
line-height: 20px;
}
.field-name-field-organizers .field-item {
line-height: 20px;
}
.field-name-field-organizers a {
font-size: 12px;
color: #30739C;
line-height: 20px;
}
}
/* === Groups directory === */
.two-33-66 {

View File

@ -0,0 +1,36 @@
<?php
/**
* @file
* Template override for upcoming events view, groups pane.
*
* - $view: The view in use.
* - $fields: an array of $field objects.
* - $row: The raw result object from the query, with all data it fetched.
*
* @see views-views-fields.tpl.php
*/
?>
<?php dpm($fields); ?>
<div class="event--large-teaser">
<div class="container-header">
<h3><?php print $fields['title_field']->content; ?></h3>
</div>
<div class="container-first">
<div class="field-body"><?php print $fields['body']->content; ?></div>
</div>
<div class="container-second">
<div class="field-date"><?php
// TODO: rewrite this part into a custom date field formatter.
$date_str = $fields['field_date']->content;
$date_str = str_replace('<div class="field-content">', '<div class="field-content"><div class="date-part">', $date_str);
$date_str = str_replace(',', '</div>', $date_str);
print $date_str;
?></div>
<div class="field-capacity"><?php print $fields['capacity_used']->content; ?></div>
<div class="field-comment-count"><?php print $fields['comment_count']->content; ?></div>
</div>
<div class="container-footer">
</div>
</div>