PHP5.2
Drupal 6.10
date 6.x.2.x (apr 1 2009)
views 6.x.2.5
cck 6.x.2.2
Using a repeating date field to sort an HTML list view causes multiple entries (per repeating event) to show up in the view, even if 'distinct' is on and 'group multiple values' for the date field is on. If you remove the sort then it shows only one entry (per repeating event) as expected.
Looks like this has been a persistent bug since 2007, refer to #140079: Sorting duplicates nodes with multiple values and others

export of the view that has no sort and therefore displays one entry per event as expected:

$view = new view;
$view->name = 'email_upcoming';
$view->description = 'Announcement email upcoming events section';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'field_datetime_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'medium',
    'multiple' => array(
      'multiple_number' => '1',
      'multiple_from' => '',
      'multiple_to' => '',
      'group' => 1,
    ),
    'repeat' => array(
      'show_repeat_rule' => 'hide',
    ),
    'fromto' => array(
      'fromto' => 'both',
    ),
    'exclude' => 0,
    'id' => 'field_datetime_value',
    'table' => 'node_data_field_datetime',
    'field' => 'field_datetime_value',
    'relationship' => 'none',
  ),
  'title' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 1,
      'max_length' => '120',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 1,
    ),
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'event' => 'event',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
  'field_show_in_email_upcoming_value_many_to_one' => array(
    'operator' => 'or',
    'value' => array(
      'Display this event in the <b>Announcements Email Upcoming Events</b> section' => 'Display this event in the <b>Announcements Email Upcoming Events</b> section',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'field_show_in_email_upcoming_value_many_to_one',
    'table' => 'node_data_field_show_in_email_upcoming',
    'field' => 'field_show_in_email_upcoming_value_many_to_one',
    'relationship' => 'none',
    'reduce_duplicates' => 0,
  ),
  'date_filter' => array(
    'operator' => '>',
    'value' => array(
      'value' => NULL,
      'min' => NULL,
      'max' => NULL,
      'default_date' => 'now',
      'default_to_date' => '',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'date_fields' => array(
      'node_data_field_datetime.field_datetime_value' => 'node_data_field_datetime.field_datetime_value',
    ),
    'date_method' => 'OR',
    'granularity' => 'hour',
    'form_type' => 'date_select',
    'default_date' => 'now',
    'default_to_date' => '',
    'year_range' => '-3:+3',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
  'grouping' => '',
  'type' => 'ul',
));
$handler->override_option('row_options', array(
  'inline' => array(
    'title' => 'title',
    'field_datetime_value' => 'field_datetime_value',
  ),
  'separator' => ' - ',
));

the view with the sort enabled, which overrides 'group multiple values' and 'distinct', and shows multiple entries per repeating event:

$view = new view;
$view->name = 'email_upcoming';
$view->description = 'Announcement email upcoming events section';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'field_datetime_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'medium',
    'multiple' => array(
      'multiple_number' => '1',
      'multiple_from' => '',
      'multiple_to' => '',
      'group' => 1,
    ),
    'repeat' => array(
      'show_repeat_rule' => 'hide',
    ),
    'fromto' => array(
      'fromto' => 'both',
    ),
    'exclude' => 0,
    'id' => 'field_datetime_value',
    'table' => 'node_data_field_datetime',
    'field' => 'field_datetime_value',
    'relationship' => 'none',
  ),
  'title' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 1,
      'max_length' => '120',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 1,
    ),
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'field_datetime_value' => array(
    'order' => 'ASC',
    'delta' => '-1',
    'id' => 'field_datetime_value',
    'table' => 'node_data_field_datetime',
    'field' => 'field_datetime_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'event' => 'event',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
  'field_show_in_email_upcoming_value_many_to_one' => array(
    'operator' => 'or',
    'value' => array(
      'Display this event in the <b>Announcements Email Upcoming Events</b> section' => 'Display this event in the <b>Announcements Email Upcoming Events</b> section',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'field_show_in_email_upcoming_value_many_to_one',
    'table' => 'node_data_field_show_in_email_upcoming',
    'field' => 'field_show_in_email_upcoming_value_many_to_one',
    'relationship' => 'none',
    'reduce_duplicates' => 0,
  ),
  'date_filter' => array(
    'operator' => '>',
    'value' => array(
      'value' => NULL,
      'min' => NULL,
      'max' => NULL,
      'default_date' => 'now',
      'default_to_date' => '',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'date_fields' => array(
      'node_data_field_datetime.field_datetime_value' => 'node_data_field_datetime.field_datetime_value',
    ),
    'date_method' => 'OR',
    'granularity' => 'hour',
    'form_type' => 'date_select',
    'default_date' => 'now',
    'default_to_date' => '',
    'year_range' => '-3:+3',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
  'grouping' => '',
  'type' => 'ul',
));
$handler->override_option('row_options', array(
  'inline' => array(
    'title' => 'title',
    'field_datetime_value' => 'field_datetime_value',
  ),
  'separator' => ' - ',
));

Thanks in advance!

Comments

cangeceiro’s picture

I can confirm this issue exists in drupal/views/date for 5 as well. removing the sort order corrects the issue. I have read several reports on this and there seems to be conflict on whether the problem is an issue with views, drupal core, or date. Any inklings into a resolution would be greatly appriciated however.

KarenS’s picture

Status: Active » Closed (won't fix)

This is a basic CCK issue, you can't sort on any grouped, multiple value CCK field because these fields are removed from the query and the multiple values are added in in the theme instead. There is just no way to sort on a value that is not in the query. The Date module handles this the same way all other CCK fields handle it, it is not a Date issue.

The work around is not try to group those values if you want to sort them.

drupalina’s picture

Component: Date Repeat API » Date API
Status: Closed (won't fix) » Active

Sorry, to re-open this issue.
I'm having a similar issue: I'm trying to construct a simple chronologically ascending table of engagements (many of which have multiple date fields, though not through Date Repeat API). Because the multiple date fields in node creation form are draggable, I'm assuming that these date fields must have some sort of weight value attached to them. Then my suggestion is: why not allow chronological sortability by the first date field?

Many thanks!

smooshy’s picture

subscribe

Exploratus’s picture

So I guess this answers why I havent been ablt to get repeating events to only display the next instance sorted by date. hmmmmm.. Seems like an abvious necessity for views / date combo...

subscribe..

Exploratus’s picture

So I guess this answers why I havent been ablt to get repeating events to only display the next instance sorted by date. hmmmmm.. Seems like an abvious necessity for views / date combo...

subscribe..

zkrebs’s picture

I think I'm having this problem..... how can you get a date field that shows repeating dates to be listed in a view as a field, but only show, say, the next 5 repeats after today's date...?

DamienMcKenna’s picture

Status: Active » Closed (won't fix)

Unfortunately the Drupal 6 version of the Date module is no longer supported. That said, we appreciate that you took time to work on this issue. Should this request still be relevant for Drupal 7 please feel free to reopen it. Thank you.