0

I'm creating an event calendar and have run into this challenge. Say I have these events:

Concert A:
1/5/2016
1/6/2016
1/8/2016

Concert B:
1/6/2016
1/7/2016
1/8/2016

I want my view to display like this:

1/5/2016
Concert A

1/6/2016
Concert A
Concert B

1/7/2016
Concert B

1/8/2016
Concert A
Concert B

Right now I have a view which only shows the first instance of an event by date, and groups/aggregates distinct instances by date. Using the above data, this is my view now:

1/5/2016
Concert A

1/6/2016
Concert B

I'm currently grouping by a Date field which is set not to display. A second "Rendered Node" field displays the node using a view mode. This is driving me nuts. Anyone pull this off before?

1 Answer 1

1

You don't need the aggregation settings to get the result you want. Instead, I think you want the "Grouping field" option under the settings of "format".

Views UI settings with select list for Grouping field

Here is the export of a full View that I think yields the results you want:

$view = new view();
$view->name = 'date_group_test';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'date_group_test';
$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['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'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['grouping'] = array(
  0 => array(
    'field' => 'field_date',
    'rendered' => 1,
    'rendered_strip' => 0,
  ),
);
$handler->display->display_options['row_plugin'] = 'fields';
/* 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']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* 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']['settings'] = array(
  'format_type' => 'long',
  'fromto' => 'both',
  'multiple_number' => '',
  'multiple_from' => '',
  'multiple_to' => '',
  'show_remaining_days' => 0,
);
$handler->display->display_options['fields']['field_date']['group_rows'] = FALSE;
$handler->display->display_options['fields']['field_date']['delta_offset'] = '0';
/* Sort criterion: Content: 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;

And a screenshot of the rendered View:

Rendered View

1
  • Yes! It's worth noting that on the Date field "Display all values in the same row" under "Multiple Field Settings" must be unchecked otherwise you'll get groups that look like "April 3, 2016, April 4, 2016." Thanks! Apr 3, 2016 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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