I am using PHP 5.

I was about to submit this to the Views 2 issue queue, but was urged by the instructions to first submit to the related module queue.

I am using the Date module to create a log of events on my website. The Date field is setup so that I can have multiple dates, each with a start and end time.

I am having a problem when setting the criteria to be "greater than or equal to now". The problem is that the node will repeat for however many dates are set for that node. If I have three dates, than it will repeat three times (as shown in the screenshot). I have tried setting the criteria for both "value" and "value2", but it doesn't make any difference. (It's not clear to me what "value2" is.)

The desired affect would be to have the event be listed once and show up in the View until the last day of the last date.

SQL:

SELECT DISTINCT(node.nid) AS nid,
   node_data_field_event_date.field_event_date_value2 AS node_data_field_event_date_field_event_date_value2,
   node.title AS node_title
 FROM node node 
 LEFT JOIN content_field_event_date node_data_field_event_date ON node.vid = node_data_field_event_date.vid
 WHERE (node.status <> 0) AND (node.type in ('event')) AND (DATE_FORMAT(STR_TO_DATE(node_data_field_event_date.field_event_date_value2, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2008-09-01')

VIEW

$view = new view;
$view->name = 'event';
$view->description = 'Event';
$view->tag = 'Event';
$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(
  'title' => array(
    'label' => 'Title',
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'field_event_date_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_event_date_value',
    'table' => 'node_data_field_event_date',
    'field' => 'field_event_date_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => 1,
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  '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',
  ),
  '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_event_date.field_event_date_value2' => 'node_data_field_event_date.field_event_date_value2',
    ),
    'granularity' => 'day',
    'form_type' => 'date_select',
    'default_date' => 'now',
    'default_to_date' => '',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('distinct', 1);
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Matthew Davidson’s picture

Here's a kludge that works for me. I am sure that as you read this, merlinofchaos is rolling up his sleeves to deliver a firm slap across my head and a much more elegant and reliable solution.

Create a template file in your theme directory appropriate for your view. For example, for a view called 'events' using the unformatted style, it would be 'views-view-unformatted--events.tpl.php'. In this file, put the following:

<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php
$seen_rows = array();
for ($i = 0; $i < count($view->result); $i++) {
  if (!in_array($view->result[$i]->nid, $seen_rows)) {
    print $rows[$i];
    $seen_rows[] = $view->result[$i]->nid;
  }
} 
?>

Of course, this assumes the contents of $view->result will always correspond to the contents of $rows. I can't say that that will always be the case, just that it hasn't screwed up for me yet.

Oh, and I think this will throw pagination and view summaries out of whack.

KarenS’s picture

Status: Active » Fixed

This is the way all CCK multiple value fields work. If you want to only see a single result, you need to choose the field option to 'group multiple values' in the field settings.

Matthew Davidson’s picture

Unfortunately you can't do this if you're not using the 'fields' row style.

capellic’s picture

Version: 6.x-2.0-rc2 » 6.x-2.0-rc3
Status: Fixed » Active

That's the odd thing - I do have the "Group multiple values" checkbox checked.

Here's the SQL query that gets produced for my View:

SELECT DISTINCT(node.nid) AS nid,
   node_data_field_event_date.field_event_date_value2 AS node_data_field_event_date_field_event_date_value2,
   node.title AS node_title,
   node.vid AS node_vid,
   node_data_field_subtitle.field_subtitle_value AS node_data_field_subtitle_field_subtitle_value,
   node_data_field_subtitle.nid AS node_data_field_subtitle_nid,
   node.type AS node_type,
   node_data_field_teaser.field_teaser_value AS node_data_field_teaser_field_teaser_value,
   node_data_field_teaser.field_teaser_format AS node_data_field_teaser_field_teaser_format,
   node_data_field_teaser.nid AS node_data_field_teaser_nid
 FROM node node 
 LEFT JOIN content_field_event_date node_data_field_event_date ON node.vid = node_data_field_event_date.vid
 LEFT JOIN content_field_subtitle node_data_field_subtitle ON node.vid = node_data_field_subtitle.vid
 LEFT JOIN content_field_teaser node_data_field_teaser ON node.vid = node_data_field_teaser.vid
 WHERE (node.status <> 0) AND (node.type in ('event')) AND (DATE_FORMAT(STR_TO_DATE(node_data_field_event_date.field_event_date_value2, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2008-10-12')

Here's my view:

$view = new view;
$view->name = 'event';
$view->description = 'Event';
$view->tag = 'Event';
$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(
  'title' => array(
    'label' => 'Title',
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'field_event_date_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => 1,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => 0,
    ),
    'exclude' => 0,
    'id' => 'field_event_date_value',
    'table' => 'node_data_field_event_date',
    'field' => 'field_event_date_value',
    'relationship' => 'none',
  ),
  'field_subtitle_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_subtitle_value',
    'table' => 'node_data_field_subtitle',
    'field' => 'field_subtitle_value',
    'relationship' => 'none',
  ),
  'field_teaser_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_teaser_value',
    'table' => 'node_data_field_teaser',
    'field' => 'field_teaser_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => 1,
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  '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',
  ),
  '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_event_date.field_event_date_value2' => 'node_data_field_event_date.field_event_date_value2',
    ),
    'granularity' => 'day',
    'form_type' => 'date_select',
    'default_date' => 'now',
    'default_to_date' => '',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('items_per_page', 0);
$handler->override_option('distinct', 1);
KarenS’s picture

Status: Active » Fixed

I think this is working correctly in -dev now, with today's commits.

alistairmcclymont’s picture

Just got the very latest dev version (and also tried rc5) i have the same problem. An event node that allows multiple dates.

I'm filtering by date > now, i've tied checking the group multiple values tick box - still showing multiple version of the same node.

If I turn off the filter i only get one copy of each node. If i turn on the filter i get a copy for each of the multiple date values that i'm filtering for. I want to say if any of the dates are greater than now in that particular node - show the node once.

alistairmcclymont’s picture

Status: Fixed » Active
amcc’s picture

I'm using rc-5 and still get this problem with group multiple values checked, but i've found a work around for this - using an argument to get the nids of the nodes you're after you can prevent nodes appearing many times for each of their multiple dates.

  • Add an argument of type 'Node: Nid'
  • Select 'Provide default argument'
  • Select 'PHP Code'
  • Use code similar to mine below:
  • Make sure you check 'Allow multiple terms per argument.'
  • Set up the view with the fields you want
  • Under Sort Criteria, if you want to sort by the date field you must set the 'Delta' to 1 if you don't want to see multiple values.
// Get future events
// counter
$i = 0;
// Get todays date as mySQL datetime
$today = date('c');
$result = db_query("SELECT DISTINCT n.nid FROM {node} n 
				INNER JOIN {content_field_event_date} d 
				ON n.nid = d.nid 
				WHERE d.field_event_date_value2 >= '%s'", $today);

while ($node = db_fetch_object($result)) {
	if ($i > 0){ $nids .= ',';}
	$nids .= $node->nid;
	$i++;
}
return $nids;

the CCK date table in my example is content_field_event_date - this needs to be changed to your CCK date table
the date field in my example is field_event_date_value2 - this needs to be changed to the name of your date field

This will return a comma separated list of nids to views.

Doing this seems to give exactly the same results as using a date filter with greater than or equal to, but eliminates multiple nodes appearing. You can obviously change the sql statement to have less than, or anything else.

Tony Sharpe’s picture

I have the same problem, currently tried with both rc6 and latest Date Dev (11th Feb 09). I have cck type called 'event' with multiple value date field. I then have a view called 'events' and in terms of describing this problem I'm talking about a page view.

If I don't check 'group by multiple values', then an event is listed multiple times and each time it displays just the one date under the event, different date for each listing. This is all valid and to me works correctly if that's what you want to do.

I want to just display the event once and list all the applicable dates underneath it. To do this I check 'group multiple values'. I do indeed get the event listed with all associated dates, but I also get the event listed again many times, each one with its own individual date. i.e. this is giving me both a grouped display and a non-grouped dispaly, all combined. This is with date rc6 and views 2.2.
I've just tried with latest date (11 Feb), and it's using Views 2.3. Ungrouped is the same as above, grouped now lists the event multiple times and each time it puts all the dates underneath the event, so I'm getting multiple listings of the event with multiple dates shown each time.

I've tried the Distict:Yes in both cases and no change. I've tried 'grouping by' but no help.

cpelham’s picture

I have the same issue and desire the same result, to be able to have the option of repeating events be displayed only once in a view. I am trying to think how to add this feature myself. I tried the suggestion in #8 but have not been able to get it working yet. But I think something similar ought to be able to work. We need to be able to intercept the query and loop through it to check for duplicates (perhaps duplicate node titles?) and then drop them or add a display:none to the repeats. However, I am not sure at what point the query converts/expands the repeating dates into essentially additional nodes to be displayed.

KarenS’s picture

Status: Active » Fixed

I just committed a new feature to -dev that should take care of this and more. The formatters now have settings so you can do choose to show or not show the repeat rule, display all repeats or the first repeat or the next repeat from today or whatever. You can also choose if you want to display both the from and to dates, or just the 'From' date or just the 'To' date.

If you use Advanced Help you'll see some popup help for this. The formatter settings are on the Display fields page and when you add Date fields to views.

I'm sure it will still need some tweaking to produce the right results everywhere, but so far in my testing it works to make this all very customizable.

If there are no immediate bugs, I'm planning to roll a new release with this in it.

cpelham’s picture

Karen, you are (still and always) a rock star!!

cpelham’s picture

Version: 6.x-2.0-rc3 » 6.x-2.x-dev
Status: Fixed » Active

Hi Karen. I just installed the new 6.x-2.x-dev and tried adding a CCK date field to a view of upcoming events and I got the following error when I re-load the views page:

Fatal error: Cannot access empty property in /drupal/sites/all/modules/date/date/date_handler_field_multiple.inc on line 127

Line 127 is:
$node->nid = $values->{$this->aliases['nid']};

Does this mean that no nid values have been assigned yet?
If so, does that mean something is going wrong in lines 64-72:

// List columns to retrieve.
$alias = content_views_tablename($field);
// Prefix aliases with '_' to avoid clashing with field columns names.
$query_columns = array(
'node.vid AS _vid',
"$alias.delta as _delta",
// nid is needed to generate the links for 'link to node' option.
'node.nid AS _nid',
);

KarenS’s picture

Status: Active » Postponed (maintainer needs more info)

I can't replicate that at all. What kind of date field are you using? What does your view and query look like? Where exactly did you run into the error, when adding the field, or when previewing it, or after the view was saved, or whatever?

cpelham’s picture

Status: Postponed (maintainer needs more info) » Active

Specifically, checking "Group multiple values" throws the error. It does not seem to matter whether I leave the number of values to be displayed or the from and two fields empty or fill them out variously. If I do not check "Group multiple values" then the view displays and the repeat rule displays as it should, but I still see multiple instance of the node in the view. So, I want to get the "Group multiple values" working again.

KarenS’s picture

Status: Active » Postponed (maintainer needs more info)

I still can't replicate this. I can select that option with no problem at all. There must be something else about your date field or view that is different than mine. Try creating a new view and adding a multiple value date to it and see what happens before adding any other filters or arguments or fields, rather than making changes to an existing view.

KarenS’s picture

Also try deleting that field and saving the view (to clear out anything that might be in the cache) and then re-add it.

cpelham’s picture

Status: Postponed (maintainer needs more info) » Active

I'm going to try re-creating the view, as I recall that has fixed other instances of views errors in the past.
In the mean time, here is an export of the view:

$view = new view;
$view->name = 'events_upcoming';
$view->description = 'Upcoming Events';
$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_event_image_fid' => array(
'label' => '',
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'youtube_linked',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_event_image_fid',
'table' => 'node_data_field_event_image',
'field' => 'field_event_image_fid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'title' => array(
'label' => '',
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'field_subtitle_value' => array(
'label' => '',
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_subtitle_value',
'table' => 'node_data_field_subtitle',
'field' => 'field_subtitle_value',
'relationship' => 'none',
),
'field_instructor_or_artist_value' => array(
'label' => '',
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_instructor_or_artist_value',
'table' => 'node_data_field_instructor_or_artist',
'field' => 'field_instructor_or_artist_value',
'relationship' => 'none',
),
'field_event_cck_date_2_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(
'group' => 0,
'multiple_number' => '1',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 1,
'id' => 'field_event_cck_date_2_value',
'table' => 'node_data_field_event_cck_date_2',
'field' => 'field_event_cck_date_2_value',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'field_text_date_value' => array(
'label' => '',
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_text_date_value',
'table' => 'node_data_field_text_date',
'field' => 'field_text_date_value',
'relationship' => 'none',
),
'field_event_fee_value' => array(
'label' => '',
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_event_fee_value',
'table' => 'node_data_field_event_fee',
'field' => 'field_event_fee_value',
'relationship' => 'none',
),
'teaser' => array(
'label' => '',
'exclude' => 0,
'id' => 'teaser',
'table' => 'node_revisions',
'field' => 'teaser',
'relationship' => 'none',
),
'field_event_cck_date_2_value_2' => 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' => 'short',
'multiple' => array(
'multiple_number' => '1',
'multiple_from' => '',
'multiple_to' => '',
'group' => 1,
),
'repeat' => array(
'show_repeat_rule' => 'show',
),
'exclude' => 0,
'id' => 'field_event_cck_date_2_value_2',
'table' => 'node_data_field_event_cck_date_2',
'field' => 'field_event_cck_date_2_value',
'relationship' => 'none',
'fromto' => array(
'fromto' => 'both',
),
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('sorts', array(
'field_event_cck_date_2_value' => array(
'order' => 'ASC',
'delta' => '0',
'id' => 'field_event_cck_date_2_value',
'table' => 'node_data_field_event_cck_date_2',
'field' => 'field_event_cck_date_2_value',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => 1,
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'event_cck' => 'event_cck',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'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_event_cck_date_2.field_event_cck_date_2_value' => 'node_data_field_event_cck_date_2.field_event_cck_date_2_value',
),
'granularity' => 'day',
'form_type' => 'date_select',
'default_date' => 'now',
'default_to_date' => '',
'id' => 'date_filter',
'table' => 'node',
'field' => 'date_filter',
'relationship' => 'none',
),
'language' => array(
'operator' => 'in',
'value' => array(
'***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
'***NO_LANGUAGE***' => '***NO_LANGUAGE***',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'language',
'table' => 'node',
'field' => 'language',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('title', 'Upcoming Events');
$handler->override_option('items_per_page', 20);
$handler->override_option('use_pager', '1');
$handler->override_option('use_more', 1);
$handler->override_option('distinct', 0);
$handler->override_option('style_options', array(
'grouping' => '',
));
$handler->override_option('row_options', array(
'inline' => array(),
'separator' => '',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'events/upcoming');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('items_per_page', 10);
$handler->override_option('style_plugin', 'views_rotator');
$handler->override_option('style_options', array(
'timeout' => '4',
'speed' => '1',
'pause' => 1,
'back_next_buttons' => 1,
'height' => '400px',
));
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);

cpelham’s picture

I made a new test View and encountered the same problem but I have perhaps isolated it a little more. I can check "Group multiple values" without throwing an error if I have no filters. As soon as I add a Date filter or a Node Type: Event CCK, I get a popup error that says "An error occurred at /drupal/admin/build/views/ajax/preview/test_view" (which I also got before) and then if i load the views page I get the same error:

Fatal error: Cannot access empty property in /home/crsnyorg/public_html/drupal/sites/all/modules/date/date/date_handler_field_multiple.inc on line 127

I am using Content Construction Kit (CCK) 6.x-2.1 and Views 6.x-2.3.

My query is:
SELECT node.nid AS nid, node.vid AS node_vid, node.type AS node_type, node_revisions.teaser AS node_revisions_teaser, node_revisions.format AS node_revisions_format, node.title AS node_title FROM node node LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid WHERE (node.status <> 0) AND (node.language in ('***CURRENT_LANGUAGE***', '***NO_LANGUAGE***'))

My exported test view is:
$view = new view;
$view->name = 'test_view';
$view->description = 'Test View';
$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_event_cck_date_2_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' => 'default',
'multiple' => array(
'multiple_number' => '1',
'multiple_from' => '',
'multiple_to' => '',
'group' => 1,
),
'repeat' => array(
'show_repeat_rule' => 'show',
),
'exclude' => 0,
'id' => 'field_event_cck_date_2_value',
'table' => 'node_data_field_event_cck_date_2',
'field' => 'field_event_cck_date_2_value',
'relationship' => 'none',
'fromto' => array(
'fromto' => 'both',
),
),
'teaser' => array(
'label' => 'Teaser',
'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,
),
'exclude' => 0,
'id' => 'teaser',
'table' => 'node_revisions',
'field' => 'teaser',
'relationship' => 'none',
),
'title' => array(
'label' => 'Title',
'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,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'language' => array(
'operator' => 'in',
'value' => array(
'***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
'***NO_LANGUAGE***' => '***NO_LANGUAGE***',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'language',
'table' => 'node',
'field' => 'language',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'test/view');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));

KarenS’s picture

I'll see if I can reproduce this now. One thing that is helpful when debugging this stuff is if you go to the Views Tools tab and check the box to turn off javascript. Then when you preview you will be able to see the actual error messages instead of "An error occurred at /drupal/admin/build/views/ajax/preview/test_view".

KarenS’s picture

Also, the place in the code that you are getting an error is identical to the CCK field handler, so you should get the same error for any CCK field. Can you try adding another CCK multiple value field to the view to see if you get an error there, too? (Create one if you have to to test this. It has to be a core field like text or number and it must be set to use multiple values).

cpelham’s picture

I made a new content type and assigned it a newly created CCK decimal field with unlimited multiple values. I created one new node of this new content type and gave it three decimal values.

I then created a new view, added the decimal field. Without group multiple values, it displays all three values as expected. With group multiple values 1, it displays only the first value as expected.

I deduced that something must be screwed up with date field or with my specific date field values.

I then created a NEW repeating date field and attached it to my new content type. I added this field in my view. Without group multiple values, it works ok. With group multiple values, it throws the same error as before:
Fatal error: Cannot access empty property in /home/crsnyorg/public_html/drupal/sites/all/modules/date/date/date_handler_field_multiple.inc on line 127

My testnode looks like this:

This is a test of the content type testnode1

test field:
12.00
23.00
34.00
testdate:
Repeats every week until Sat Mar 28 2009 .
February 28, 2009 3:02pm - 4:02pm
March 7, 2009 3:02pm - 4:02pm
March 14, 2009 3:02pm - 4:02pm
March 21, 2009 3:02pm - 4:02pm

The export of the new testview looks like this:

$view = new view;
$view->name = 'test_view';
$view->description = 'Test View';
$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(
'title' => array(
'label' => 'Title',
'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,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'field_testfielddecimal_value' => array(
'label' => 'test field',
'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' => 'widget',
'format' => 'default',
'multiple' => array(
'group' => 1,
'multiple_number' => '1',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_testfielddecimal_value',
'table' => 'node_data_field_testfielddecimal',
'field' => 'field_testfielddecimal_value',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
'field_testdate_value' => array(
'label' => 'testdate',
'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' => 'widget',
'format' => 'default',
'multiple' => array(
'multiple_number' => '1',
'multiple_from' => '',
'multiple_to' => '',
'group' => 1,
),
'repeat' => array(
'show_repeat_rule' => 'show',
),
'exclude' => 0,
'id' => 'field_testdate_value',
'table' => 'node_data_field_testdate',
'field' => 'field_testdate_value',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'fromto' => array(
'fromto' => 'both',
),
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'test' => 'test',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'test/view');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));

biohabit’s picture

FYI this bug is large enough that it breaks a test copy upgrade date 2.0 from 2.0-rc6 I get the following text on a blank/white screen on any URL I attempt to load ( /, /calendar, /admin, /user, ....).

Fatal error: Cannot access empty property in [snip]/sites/all/modules/date/date/date_handler_field_multiple.inc on line 127

I've run the update.php three times with no change and have tried several different copies of my production site which is www.thedirt.org.

cpelham’s picture

I only get that error when I have Group Multiple Dates checked. Try un-checking it and see if the error goes away. Of course, like me, you may need to have that setting checked, so this is not a solution to the apparent bug, but just away to help isolate it.

tanc’s picture

Confirmed that turning off Group Multiple Dates stops this error. Unfortunately I also need to group multiple dates.

cpelham’s picture

Karen, will you be at DrupalCon? Would it be possible to try to solve this there? Perhaps if you could see my installation, it would be of help? I took a php class but still find it hard to jump into a complex drupal module and follow the code, or not so much the code but to understand what all the variables and objects are well enough to help debug. If you are there and have a BoF on your modules I'd love to attend.

ericm’s picture

I'm having the same problem as comment #13 by cpelham above, a PHP error, "Fatal error: Cannot access empty property in /drupal/sites/all/modules/date/date/date_handler_field_multiple.inc on line 127" and documented with exports here #386574: Fatal error: Cannot access empty property in...date_handler_field_multiple.inc.... I haven't explored it as extensively as others on this thread, though, so this is just a "me too."

FoolsRun’s picture

I can throw a "me, too" in as well. My whole site was hosed by this bug until I managed to disable a block which showed upcoming events (date >="now").

cedrix’s picture

subscribe...

Anonymous’s picture

I also am getting the same effect.

The JS error "An error occurred at /drupal/admin/build/views/ajax/preview/test_view" comes up as described in #19 & #20, though if I turn JS off, or call up the View page directly I just get a totally white blank screen, with no error report at all.

Other repeated CCK fields work OK, as described in #22 (I tried a text field).

The error occurs when Group Multiple Values is set on a Date field that has multiple values, whether using Repeated Dates popup, or allowing multiple values of a single date field (if that makes sense).

Regards, Tony

laryn’s picture

I just did a module upgrade, ran the database update script (which had an error on first run and had to be run again) and then a page that had a views block for "upcoming events" crashed the whole front page. Currently turned that block off but would love a solution.

orbgasm’s picture

bump

like #31, I had to run update.php twice to get the 60005 update to work. I did however narrow down the case in which I am experiencing this issue.

I am specifically receiving the error "Fatal error: Cannot access empty property in [snip]/modules/date/date/date_handler_field_multiple.inc on line 127" when I allow the cck field to have more than 1 value.

seems to be the same exact error cpelham is getting.

If i have it set to allow only 1 entry, whether the view that displays this field is set to group multiple values or not, it works fine.

So basically, the same issue as #30, and the same error as cpelham initially stated in #13

plach’s picture

we found this workaround, but we're not sure it's really the solution, needing karen's feedback.

plach’s picture

Status: Active » Needs review
Anonymous’s picture

Ref #33. Which particular piece of the problem does this address? - there are several running in this thread.

Thanks, Tony

plach’s picture

@maynardsmith: the multiple dates issue cited in #13.

cpelham’s picture

Status: Needs review » Fixed

Sitting with Karen at DrupalCon, we found that updating to the current CCK Dev resolved the error.

Rather than applying this patch, you can just update to the latest dev version of CCK.

kepford’s picture

Same issue as some above. I have a calendar block that loads on each page so I am white screening on every page. I am using multiple dates in this block.

Subscribing

cpelham’s picture

bobkepford: Please provide more information. Are you running the latest dev versions of CCK, Date, Calendar and Views? If not, please update, try again, and report back. Also, report on the specifics of how your view is set up. It is helpful to follow Earl Miles' guidelines for posting to the Views issue queue:

try clearing your cache (administer >> site building >> views >> tools) as Views caches data provided by modules. This is especially relevant if the bug appeared after you upgraded Views or a module that contains Views support. If using Views 2:
If your issue report is about a view that provides unexpected results, or about a SQL error, PLEASE export the entire view and paste it between tags. Please also paste the query from the live preview; you can put the query between tags to preserve formatting.

If you only read one of these submission guidelines, read this one. (Then please read the rest) If your problem deals exclusively with fields or filters provided by another module (CCK, Image, VotingAPI are common) please post the issue under the queue for that module first; all modules are responsible for telling Views about their own fields. It's possible Views IS at fault, but the module maintainers are the best people to make that determination, and they can kick the issue into the Views queue with an explanation of what's wrong if that is the case.

If you are getting a crash bug, please explain precisely what you were trying to do/accomplish with the View at the time.
If you are getting a white screen while installing Views, please be sure you have at least 24MB memory available for PHP (google search can easily tell you how); and this can go up if you have a lot of modules. There is extra memory processing on the modules screen due to menu rebuilds and Views will build its first data cache on that page as well, so lots of things will come together to use memory.

If there's a crash of some kind and you don't get any kind of error message, be sure to check your apache/php error log. (The location varies from server to server but every server should have one).

trackleft’s picture

That is so sick that you guys met up at DrupalCon to fix an error. Legit!!! The solution worked for me.

TimG1’s picture

Man, sorry guys. I'm having the same problem with the Group Multiple Values option. =( It works fine in calendar view. When Group Multiple Values is unchecked, I see all the repeat values as expected. But, can't get the view working when Group Multiple Values is checked. Am I just overlooking something simple?

I am using...

Drupal: 6.10
Date: 6.x-2.x-dev
Views: 6.x-2.3
CCK: 6.x-2.1

The error I'm getting is:
Fatal error: Cannot access empty property in sites/all/modules/date/date/date_handler_field_multiple.inc on line 127

I tried

  • Made sure that I ran update.php
  • clearing all drupal cache
  • going to site building > Views > Tools and clearing Views cache
  • Creating a new view from scratch and adding my date field in my blank view.

Below is an export of my test view.

$view = new view;
$view->name = 'class_test';
$view->description = 'test';
$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(
'title' => array(
'label' => 'Title',
'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,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'field_course_testdate_value' => array(
'id' => 'field_course_testdate_value',
'table' => 'node_data_field_course_testdate',
'field' => 'field_course_testdate_value',
),
));
$handler->override_option('arguments', array(
'date_argument' => array(
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'date_fields' => array(
'node_data_field_course_testdate.field_course_testdate_value' => 'node_data_field_course_testdate.field_course_testdate_value',
),
'year_range' => '-3:+3',
'date_method' => 'OR',
'granularity' => 'month',
'id' => 'date_argument',
'table' => 'node',
'field' => 'date_argument',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'webform' => 0,
'image' => 0,
'class' => 0,
'file' => 0,
'front_page' => 0,
'in_the_media' => 0,
'landing_page' => 0,
'newsletter' => 0,
'news_item' => 0,
'page' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'5' => 0,
'6' => 0,
'7' => 0,
'3' => 0,
'2' => 0,
'4' => 0,
),
'validate_argument_type' => 'tid',
'user_argument_type' => '',
'restrict_user_roles' => 0,
'user_roles' => array(),
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'class' => 'class',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('fields', array(
'title' => array(
'label' => 'Title',
'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,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'field_course_testdate_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' => 'default',
'multiple' => array(
'multiple_number' => '1',
'multiple_from' => '',
'multiple_to' => '',
'group' => 0,
),
'repeat' => array(
'show_repeat_rule' => 'show',
),
'fromto' => array(
'fromto' => 'both',
),
'exclude' => 0,
'id' => 'field_course_testdate_value',
'table' => 'node_data_field_course_testdate',
'field' => 'field_course_testdate_value',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
));
$handler->override_option('path', 'testingdate');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));

Thanks everyone,
-Tim

cpelham’s picture

rhythmDude: Are you using the latest Dev versions of CCK, Date, Calendar and Views?

TimG1’s picture

Argh! I read through this thing so many times and I *still* missed it. You mentioned it at least twice in #39 and #37.

I needed the Dev version of CCK, Views, Calendar too, not just the Date module. At least at the time of this post.

Sorry, been looking at my current project too long. Thanks for the extra set of virtual eyes!

Thanks cpelham, Karen, et al. =)

-Tim

wuf31’s picture

Status: Fixed » Active

@ rhythmDude,

can you confirm that the latest dev of cck, views and date fix the problem ?
Got here from #329094: Duplicate nodes in view when field with multiple values in field set, for me the latest dev version of the above module as of current date, still has not solve my case yet.

It doesn't seem that the SQL has GROUP BY in it.
Am resorting to views query_alter hook for now to manually add the group by clause..

function datecustom_views_query_alter(&$view, &$query) {
  if ($view->name == 'schedule') {
    $query->fields['node_data_field_ev_date_field_ev_date_value']['aggregate'] = 'min';
    $query->add_groupby('nid');  
  }
}

I also need to patch current views-dev to file: includes/query.inc to allow me to use 'min' aggregation.

      if (!empty($field['count'])) {
        $string = "COUNT($string)";
        $has_aggregate = TRUE;
      }
      else if (!empty($field['aggregate'])) {
        $string = $field['aggregate'].'('.$string.')';        // Add This line, around line 940
        $has_aggregate = TRUE;
      }
      else {
        $non_aggregates[] = $fieldname;
      }
cpelham’s picture

Well, it solves the problem of the error on line 127. I no longer get any error message.

However, my events with multiple dates still appear multiple times in a view list, even if group multiples 1 is selected. But since DrupalCon I haven't had a chance to go back into it. I'll try to do so and provide more info and look at your proposed patch.

philsward’s picture

I too had weird issues with the now=> so I changed it altogether to the 'between' operative. So, between now and +1 month or between now +1 year. Works great!

cpelham’s picture

I just had a chance to update to the current dev of date and views (and calendar). My repeating dates still show up repeatedly in a (non-calendar) view, even with group multiples 1 set. I have also set delta to 1 in my sort by date settings as someone suggested.

Here is my query:


Query	
SELECT node.nid AS nid, node_data_field_event_image.field_event_image_fid AS node_data_field_event_image_field_event_image_fid, node_data_field_event_image.field_event_image_list AS node_data_field_event_image_field_event_image_list, node_data_field_event_image.field_event_image_data AS node_data_field_event_image_field_event_image_data, node.type AS node_type, node.vid AS node_vid, node.title AS node_title, node_data_field_event_image.field_instructor_or_artist_value AS node_data_field_event_image_field_instructor_or_artist_value, node_data_field_event_image.field_instructor_or_artist_format AS node_data_field_event_image_field_instructor_or_artist_format, node_data_field_event_image.field_text_date_value AS node_data_field_event_image_field_text_date_value, node_data_field_event_image.field_text_date_format AS node_data_field_event_image_field_text_date_format, node_data_field_event_image.field_event_fee_value AS node_data_field_event_image_field_event_fee_value, node_data_field_event_image.field_event_fee_format AS node_data_field_event_image_field_event_fee_format, node_revisions.teaser AS node_revisions_teaser, node_revisions.format AS node_revisions_format, node_data_field_event_cck_date_2.field_event_cck_date_2_value AS node_data_field_event_cck_date_2_field_event_cck_date_2_value FROM node node  LEFT JOIN content_field_event_cck_date_2 node_data_field_event_cck_date_2 ON node.vid = node_data_field_event_cck_date_2.vid LEFT JOIN term_node term_node ON node.vid = term_node.vid AND term_node.tid = 248 LEFT JOIN content_type_event_cck node_data_field_event_image ON node.vid = node_data_field_event_image.vid LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid WHERE ((node.type in ('event_cck')) AND (node.status <> 0) AND (node.language in ('***CURRENT_LANGUAGE***', '***NO_LANGUAGE***')) AND (term_node.tid IS NULL)) AND ((DATE_FORMAT(STR_TO_DATE(node_data_field_event_cck_date_2.field_event_cck_date_2_value, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2009-04-03' AND DATE_FORMAT(STR_TO_DATE(node_data_field_event_cck_date_2.field_event_cck_date_2_value, '%Y-%m-%dT%T'), '%Y-%m-%d') <= '2009-06-03')) ORDER BY node_data_field_event_cck_date_2_field_event_cck_date_2_value ASC

Here is my view:


$view = new view;
$view->name = 'events_upcoming';
$view->description = 'Events Upcoming';
$view->tag = 'events';
$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_event_image_fid' => 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' => 'youtube_linked',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_event_image_fid',
    'table' => 'node_data_field_event_image',
    'field' => 'field_event_image_fid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'title' => array(
    'label' => '',
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'field_subtitle_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => 1,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => 0,
    ),
    'exclude' => 0,
    'id' => 'field_subtitle_value',
    'table' => 'node_data_field_subtitle',
    'field' => 'field_subtitle_value',
    'relationship' => 'none',
  ),
  'field_instructor_or_artist_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_instructor_or_artist_value',
    'table' => 'node_data_field_instructor_or_artist',
    'field' => 'field_instructor_or_artist_value',
    'relationship' => 'none',
  ),
  'field_event_cck_date_2_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' => 'show',
    ),
    'fromto' => array(
      'fromto' => 'both',
    ),
    'exclude' => 1,
    'id' => 'field_event_cck_date_2_value',
    'table' => 'node_data_field_event_cck_date_2',
    'field' => 'field_event_cck_date_2_value',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'field_text_date_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_text_date_value',
    'table' => 'node_data_field_text_date',
    'field' => 'field_text_date_value',
    'relationship' => 'none',
  ),
  'field_event_fee_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_event_fee_value',
    'table' => 'node_data_field_event_fee',
    'field' => 'field_event_fee_value',
    'relationship' => 'none',
  ),
  'teaser' => array(
    'label' => '',
    'exclude' => 0,
    'id' => 'teaser',
    'table' => 'node_revisions',
    'field' => 'teaser',
    'relationship' => 'none',
  ),
  'field_event_cck_date_2_value2' => array(
    'label' => 'event_date_cck',
    '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' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'multiple_number' => '1',
      'multiple_from' => '',
      'multiple_to' => '',
      'group' => 1,
    ),
    'repeat' => array(
      'show_repeat_rule' => 'show',
    ),
    'fromto' => array(
      'fromto' => 'both',
    ),
    'exclude' => 1,
    'id' => 'field_event_cck_date_2_value2',
    'table' => 'node_data_field_event_cck_date_2',
    'field' => 'field_event_cck_date_2_value2',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'field_event_cck_date_2_value' => array(
    'order' => 'ASC',
    'delta' => '0',
    'id' => 'field_event_cck_date_2_value',
    'table' => 'node_data_field_event_cck_date_2',
    'field' => 'field_event_cck_date_2_value',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'event_cck' => 'event_cck',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
  'status' => array(
    'operator' => '=',
    'value' => 1,
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'date_filter' => array(
    'operator' => 'between',
    'value' => array(
      'value' => NULL,
      'min' => NULL,
      'max' => NULL,
      'default_date' => 'now',
      'default_to_date' => 'now +2 months',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'date_fields' => array(
      'node_data_field_event_cck_date_2.field_event_cck_date_2_value' => 'node_data_field_event_cck_date_2.field_event_cck_date_2_value',
    ),
    'date_method' => 'OR',
    'granularity' => 'day',
    'form_type' => 'date_select',
    'default_date' => 'now',
    'default_to_date' => 'now +2 months',
    'year_range' => '-3:+3',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'language' => array(
    'operator' => 'in',
    'value' => array(
      '***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
      '***NO_LANGUAGE***' => '***NO_LANGUAGE***',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'language',
    'table' => 'node',
    'field' => 'language',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'tid' => array(
    'operator' => 'not',
    'value' => array(
      '248' => '248',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'type' => 'select',
    'vid' => '15',
    'id' => 'tid',
    'table' => 'term_node',
    'field' => 'tid',
    'hierarchy' => 0,
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
    'reduce_duplicates' => 0,
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('title', 'Upcoming Events');
$handler->override_option('items_per_page', 20);
$handler->override_option('distinct', 0);
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'events/upcoming');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

cpelham’s picture

Regarding the query I posted in #47: I don't recognize anything that would implement the group multiple = 1. Maybe I've just been staring at it too long. Karen, is there a setting that I have forgotten about?

wuf31’s picture

@ cpelham,
You can try my patch..

PS: You're not alone, I've been staring at it for quite some time too.. :D

cpelham’s picture

@ wuf31,

Into which file do I add your function datecustom_views_query_alter ?

wuf31’s picture

@cpelham,

datecustom is a custom module.
Create a new folder in the sites/all/modules/datecustom.
Create a new file in that folder datecustom.module (Put the function into it, don't forget to change the view name and the field name, if i'm not mistaken, your field name should be node_data_field_event_cck_date_2_field_event_cck_date_2_value)
Copy date.info file into the folder above, rename it to datecustom.info, and edit the file accordingly.

sifuhall’s picture

I updated my modules today and just wanted to add that I am having the issue with repeating dates as well. I have updated to the dev version of CCK with no luck.

cpelham’s picture

@wuf31
I tried adding your module and patch to views but I never could get the module to activate. The modules page would always time out. I even raised the max time limit to 600 seconds and still it would time out.

wuf31’s picture

FileSize
510 bytes

@cpelham,

Try this one..

cpelham’s picture

@wuf31,

I got it working now. Of course, I had a typo in my .info file. Thanks! It does indeed make suppress the duplicates.

sifuhall’s picture

Just an update. It appears I am having issues with repeating dates showing up multiple times and the now() isn't working as well either.

Here is my query:

SELECT node.nid AS nid,
node.type AS node_type,
node.vid AS node_vid,
node.title AS node_title,
node_revisions.body AS node_revisions_body,
node_revisions.format AS node_revisions_format,
node_data_field_dateandtime.field_dateandtime_value AS node_data_field_dateandtime_field_dateandtime_value
FROM node node
LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
LEFT JOIN content_field_dateandtime node_data_field_dateandtime ON node.vid = node_data_field_dateandtime.vid AND node_data_field_dateandtime.delta = 0
WHERE (node.status <> 0) AND (node.type in ('masonic_event'))
ORDER BY node_data_field_dateandtime_field_dateandtime_value ASC

Here is my view:

$view = new view;
$view->name = 'upcoming_events';
$view->description = 'Upcoming Events';
$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_dateandtime_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' => 1,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'group' => 1,
),
'repeat' => array(
'show_repeat_rule' => 'show',
),
'fromto' => array(
'fromto' => 'both',
),
'exclude' => 0,
'id' => 'field_dateandtime_value',
'table' => 'node_data_field_dateandtime',
'field' => 'field_dateandtime_value',
'relationship' => 'none',
),
'title' => array(
'label' => '',
'link_to_node' => 0,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'body' => array(
'label' => '',
'exclude' => 0,
'id' => 'body',
'table' => 'node_revisions',
'field' => 'body',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'field_dateandtime_value' => array(
'order' => 'ASC',
'delta' => '0',
'id' => 'field_dateandtime_value',
'table' => 'node_data_field_dateandtime',
'field' => 'field_dateandtime_value',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'date_filter' => array(
'operator' => 'between',
'value' => array(
'value' => NULL,
'min' => NULL,
'max' => NULL,
'default_date' => 'now',
'default_to_date' => 'now +1 month',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'date_fields' => array(
'node_data_field_dateandtime.field_dateandtime_value' => 'node_data_field_dateandtime.field_dateandtime_value',
),
'date_method' => 'OR',
'granularity' => 'day',
'form_type' => 'date_select',
'default_date' => 'now',
'default_to_date' => 'now +1 month',
'year_range' => '-0:+1',
'id' => 'date_filter',
'table' => 'node',
'field' => 'date_filter',
'relationship' => 'none',
),
'status' => array(
'operator' => '=',
'value' => 1,
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'masonic_event' => 'masonic_event',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('items_per_page', 5);
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);

wuf31’s picture

Status: Active » Needs work

@celpham,

Glad to hear that it's working :)
Now, let's wait what the others' thought..

davidteall’s picture

I have a related problem. I have various repeating events but I want them to show up every time - not just once. If an event takes place every week I want it to show up every week so that people don't miss it. However, if I set up my repeats for a year, I don't want the node to list all 52 repeating dates.

I have raised this problem here:

http://drupal.org/node/427932#comment-1454006

I have tried every permutation of the relatively new Date Formatter Display in the Events Content Type Display Fields but nothing will get rid of the 52 dates displaying on the node.

I am using the latest 6.x x.x-dev versions of all the relevant modules.

capellic’s picture

I upgraded all my modules and it didn't for for me, either.

The solution I came up with is mini module that takes care of the duplicates by purging rows with duplicate node IDs from the Views result set. I would hope that this could be a checkbox in Views at some point.

I've posted the recipe to my blog: http://capellic.com/blog/cure-duplicate-nodes-in-a-view

This would be a solution with any view that is displaying a node more than once due to whatever reason.

giggler’s picture

Is there a way for #60's solution be implemented...i guess into views?

wuf31’s picture

#60 solution is just a workaround and not a true fix.
It has the potential of paging issues AFAIK.

giggler’s picture

I actually tried it and the code came up on the top of every page! So I had to delete it, maybe I didn't do it right but I thought I followed the instructions...

sifuhall’s picture

This issue is really causing me problems and I've had to keep the block affected by this issue for 3 full weeks now.

I dare not upgrade my other sites that are running older version because of this issue.

Can anyone confirm if installing an older version of views will fix this?

Rob T’s picture

#60 - Your module seems to work for me when all other "fixes" seem to fail. I suppose I'll have to keep an eye out for the issues some folks have encountered.

A few things I had to do to get your module working...

1. Add PHP tags to top, bottom of module code.
2. Eliminate $query from function variable, leaving just the $view parameter
3. Change your view name (events) to my view name

Voila! Now I'm just crossing my fingers that issues don't bite me in my butt.

capellic’s picture

@Rob T (#65). Thanks for the feedback.

1. I have added the initial php tag, but not the closing tag - it's not needed and the experts claim there is a slight performance hit when using it.
2. I have removed the $query parameter. Another user pointed that out on my blog at around the same time I noticed the errors in my log.
3. Of course, you'll need to change the view name to match yours. I also found out that you *can* control it at the display level. I have updated my blog entry to reflect this: http://capellic.com/blog/cure-duplicate-nodes-in-a-view

davidteall’s picture

With the newest versions of Date and Views I can at long last control the number of repeats that show. A great improvement.

The individual entry shown in a View now shows the next date on which the event will take place rather than the first date in the series which used to be the case. This is also a great improvement. Unfortunately, it shows this date for every incidence of the event rather than showing the correct date on each occasion. To see what I mean, have a look here:

http://www.oundledeanery.org.uk/events

Scroll down and look for the repeating event 'Thrapston Parish Prayers - Mondays'. It shows up in the correct place in sequence for the whole of 2009 but it displays the same date (the date of the next occurrence) every time. It ought to display the correct date each time i.e one week further on for each occurrence.

(I have posted the same report here: http://drupal.org/node/427932#comment-1695450)

random.op’s picture

On my site, I was running into the same problem as the original poster for this thread. That is, multiple date entries would cause repeated printings of the same nid's. This was only happening when I put a filter on the view that would make is so that only the events that were yet to happen would show up in the view.

Solution for me:
After reading this thread, I decided (reluctantly) to try the dev versions of the modules to see if it fixed the problem.
All I did was upgrade the Date and the Views modules to the latest devs.

This seems to have fixed the redundancy problem for my site. I will report back if there is any unexpected behavior from using the dev versions of the modules.

Anonymous’s picture

I think that if you check "Rewrite the output of this field" for the date field in Views, and then enter the appropriate token for your date field (in my case "[field_date_value]") it will display the date correctly for each node.

will_in_wi’s picture

Status: Needs work » Active

I am having the same issue. I have duplicate entries when I set a filter on the date. I cannot figure out any way to eliminate them. I originally used the node row style, but switched to fields for testing. This happens in both. When I remove the date filter the duplicates disappear, but I do need to filter on the date, so this is not a solution.

I am running the -dev version of views and the latest releases of cck, date, and calendar. The timestamp on the dev versions of date and calendar are the same as the release versions, so I assume that they are identical. Drupal 6.

capellic’s picture

@will_in_wi: You may want to try this solution that was posted as a comment to my blog just today. I haven't tried it, but thought I'd pass it along.

http://capellic.com/blog/cure-duplicate-nodes-in-a-view#comment-29

sean porter’s picture

Hi there, I've been having the same issue listed here, trying to build a list of "upcoming events" with events which have multiple dates. As mentioned here the view was returning duplicate entries once I added a sort filter to sort by content: date.

just updated to latest 6.x dev versions of date, calendar, cck, and views. Still didn't work. Tried exporting my view and importing it into a new view. Still didn't work. Rebuilt the view from scratch (unfortunately a complex one) and the duplicates have disappeared. There's no empirical difference between the two, except one I built after updating the modules. I'm not running any of the mini-modules or patches mentioned here.

Hope this helps,
Sean

capellic’s picture

@sean porter, #72

Did you run update.php after upgrading but before rebuilding your views? Just wondering if you left out that step and if it may have made a difference?

sean porter’s picture

@capellic,

I did run update.php after the module update and before the view rebuild.

I have bad news though, its not fixed. I had forgotten one of the date filters, and upon applying it, the duplicates returned.

It looks like it has something to do with the combination of 'Sort Criteria-- Content: Date' and 'Filters-- Date: Date' (one to sort the nodes by event date in ascending order and one to filter only events that haven't happened yet) if both of them are enabled, I get dupes. if just one of them is enabled, no dupes. Frustrating!

sean porter’s picture

#71-

Just tried this method as described following the link. I had to remove the php tags before pasting it into the text box. This worked as desired!

random.op’s picture

not this bug again... :(

a couple of months ago, I decided to use the dev releases of Date and Views to solve this problem. It did just that.

Now, I have just upgraded to Drupal 6.14 and decided to update the calender, date and views modules to the newest releases. (normal behaviour for a Drupal user, I would assume)

now the redundancy issue is back again!

the following link fixed the issue for me also, as it did previous poster (-71):
http://capellic.com/blog/cure-duplicate-nodes-in-a-view#comment-29

although this fixes the problem for now. It would be nice to see redundancy of events like this solved in future release of these modules.

muka’s picture

I use this.
It's a bad rewrite of the query, but seems to work.
hope this help.


function views_views_pre_execute(&$view) {

  $nid_field = "node.nid";

// here I customize by the effective nid to be filtered in specific view
// in views ui, the preview show the quey with the avail fields specified

  if($view->name='servizi' && $view->display_id = 'block_2')
    $nid_field = "node_node_data_field_sotto_servizio.nid";



  if(strpos($view->build_info['query'], "GROUP BY") === FALSE && $has_nid=is_int(strpos($view->build_info['query'], "$nid_field"))){

    if(is_int(strpos($view->build_info['query'], "LIMIT"))){
      $view->build_info['query'] = str_replace("LIMIT", "GROUP BY $nid_field LIMIT", $view->build_info['query']);
    }
    elseif(is_int(strpos($view->build_info['query'], "GROUP BY"))){
      $view->build_info['query'] = str_replace("ORDER BY", "GROUP BY $nid_field ORDER BY", $view->build_info['query']);
    }
    else{
      $view->build_info['query'] .= " GROUP BY $nid_field";
    }

  }
// var_dump($view->name, $view->build_info['query']);
}

BenK’s picture

Subscribing.... I am also experiencing this issue on Date 6.x-2.4.

Shiraz Dindar’s picture

same issue as #74 when using the same filters.

raspberryman’s picture

Here is a solution that worked for me (using nodes, not fields, however I think it could be adapted).

// In your node template, contemplate, or preprocess_node function

  $date = $view->result[$view->row_index]->node_data_field_mydate_value;  // Full name as provided by view, begins with node_data_field_xxxx
  if (is_array($node->field_mydate)) {
    foreach ($node->field_mydate as $delta => $info) {
      if ($info['value'] == $date) {
        $delta_key = $delta;
        break;
      }
    }
  }
  
  if (empty($delta_key)) {
    $delta_key = 0;
  }

  // Now you can access the rendered content with $node->field_myevent[$delta_key]['view'] or ['value'].  
weblance’s picture

I feel sick

YK85’s picture

I was wondering if this is still an issue?
I'm about to start using Date module =)
Thanks!

rbrownell’s picture

+1 Subscribe. I would almost consider this critical.

rbrownell’s picture

Status: Active » Fixed

I just realized. In the left hand column of views. (Which is full of Views goodies.) Selecting "Distinct" will eliminate duplicate nodes.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

amogiz’s picture

I must reopen this post as I work on D7 and have exactly the saw problem.
Is There any solution for this ?

kgg’s picture

Make sure you have "Group multiple values" turned off...

Karl

frodopwns’s picture

D7 -> right column under "advanced" -> select "Query Settings" then check "distinct"

Or you can do it this way

function hook_views_pre_render(&$view) {
  $used_nids = array();

  if ($view->name == 'accents') {
    if ($view->current_display == 'page') {
      foreach ($view->result as $row) {
        if (!in_array($row->nid, $used_nids)) {
          $new_view_result[] = $row;
          $used_nids[] = $row->nid;
        }
      }
   
      $view->result = $new_view_result;
    }
  }
}
undersound3’s picture

hook function provided in #88 worked for me. Thanks @frodopwns!

kreatIL’s picture

#88 did it for me. Nice workaround.

knalstaaf’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Closed (fixed) » Active

It's not working in my case. I also saw this fine description in the Query Settings (#88) dialogue: "You can use this to try and remove duplicates from a view, though it does not always work."

I'm having this issue using a Date field. What does work, garantueed (tried the code provided in #88 as well)?

knalstaaf’s picture

Priority: Normal » Major
FileSize
5.12 KB

The issue occurs when you use the same Date field as both a filter criterium and a sort criterium.

In my case:

  • [Event date] Filter criterium: is greater or equals now.
  • [Event date] Sort criterium: Ascending.
knalstaaf’s picture

Priority: Major » Normal
Status: Active » Needs review

This method seems to work, but I'm not sure if it's supposed to work this way.

Change the topic's status if deemed appropriate.

In Filter Criteria, I added "Content: Date:delta (= 0)"

Source: #1118288: Multiple rows on multi-value date fields

Status: Needs review » Needs work

The last submitted patch, views_date_multiple-302498-33.patch, failed testing.

inversed’s picture

Unfortunately, the method mentioned in #93 works in general, however, the end result may not be exactly what you expect.

In particular, if you are filtering by upcoming dates and the field's first date (delta 0) is in the past but subsequent dates are in the future, no row will be returned.

hot_sauce’s picture

I was having this issue - I had an event with multiple dates entered by the user and was getting a record output for every date that was entered. After much digging and reading of this issue and others, I found a solution using the Views Distinct module.

The module adds an additional setting to the Field options for Views Distinct, allowing you to Filter (remove) or Aggregate (combine) multiple rows. I tried first applying this to the title but in my case, it would remove duplicates if someone entered say, an event in May as one node and then the same event in June. What I did then was to add Content: NID and then exclude it from display and THEN apply the "filter" option on the NID field. That removed the duplicates but kept the events with the same title, but different dates, to still show.

I did NOT set any DISTINCT settings in the View itself as has been mentioned before, the Views Distinct module handled that perfectly. YMMV but this technique really helped me!

jmuzz’s picture

Many of the suggested solutions do work for a block or a single page view, but none of them seem to work with a pager. At best I can get one instance of each node to appear on each page of results, causing page after page that just show a few nodes each when there should be 2 full pages of results with no 3rd page for the number of nodes I have.

amh5514’s picture

#96 solved my problem perfectly. I only have 4 to 5 items to show and do not have a need for a pager.

amh5514’s picture

*Update*

It works, as it only shows one title per NID but I guess I am using a pager and it still counts each date as an instance. Example, If I have 4 nodes with each node containing 2 dates and set the pager to show 4 items, it will only show titles to 2 nodes, counting the 2 dates per nodes as pager items.

amh5514’s picture

*Update*

Was able to get it to work by adding a date field to the view and select "Filter Repeats" in the views distinct settings option. Now all 4 node title show despite the number of dates.

jproctor’s picture

I started thinking about how #93 could be turned into a patch, and got stuck on the question of selecting only delta 0 when any delta matches (or a possible config option: when all deltas match). I'm pretty sure it's possible to include a subquery in the view, but it's beyond my skill and I didn't really have time to investigate it.

My particular use case requires a specific result count but no pagination for additional results, and my result sets are fairly small, so I ended up writing a custom pager plugin that runs an internal filter like #88 in post_execute() before truncating the result set to the length I want.