3

When using repeat date API on a field, Drupal allows you to group events so they don't appear multiple times.

However, when sorting by date it seems like Drupal ALWAYS shows all of the entries no matter what.

How can this be avoided?

6 Answers 6

14

I just ran into this issue myself. The solution is to add a filter of the date delta field =0. This means only show the 0th (first) matching item and hide any repeating values.

Hope this helps someone. Selwyn

3
  • can you take a screen shot of what you mean. im not sure where that setting is. thanks! Commented Apr 19, 2014 at 17:55
  • This new filter will make the query only consider the first instance of a repeated date. If you filter out passed end dates, or only include future start dates, it will not consider the other date instances and nodes where the first instance has passed will all be excluded.
    – TwoD
    Commented Jun 2, 2014 at 9:56
  • 1
    Given the comments here, and in regards to original question, this solution works for an event goes for a number of days but the only option for someone to attend is if they attend the first day. Consider a educational program that goes for 3 days. In order to attend it, you have to start on day 1 and complete the next few days. It is open to people joining in the middle. In that case, this solution works well.
    – PWM
    Commented Jun 28, 2015 at 19:03
3

the delta option only works when you display fields, but if your displaying a display content node it wont work. I'm using display suite to manage the output of the display so the delta field wont work. What i did was create a views specific template file:

views-view-list--event-calendar.tpl.php

I basically detect if there is a duplicate and just make a conditional to bypass the output of it.

The live page is here: http://www.xcubicle.com/events

  1 <?php
  2
  3 /**
  4  * @file
  5  * Default simple view template to display a list of rows.
  6  *
  7  * - $title : The title of this group of rows.  May be empty.
  8  * - $options['type'] will either be ul or ol.
  9  * @ingroup views_templates
 10  */
 11
 12 
 13 
 14
 15 $rows = array_unique($rows);
 16
 17 ?>
 18 <?php print $wrapper_prefix; ?>
 19   <?php if (!empty($title)) : ?>
 20     <h3><?php print $title; ?></h3>
 21   <?php endif; ?>
 22   <?php print $list_type_prefix; ?>
 23     <?php foreach ($rows as $id => $row): ?>
 24         <li class="<?php print $classes_array[$id]; ?>"><?php print $row; ?></li>
 25     <?php endforeach; ?>
 26   <?php print $list_type_suffix; ?>
 27 <?php print $wrapper_suffix; ?>
2
  • the "date field delta = 0" solution by @Selwyn Polit works for me in with display suite /fields display.
    – Dalmaz
    Commented Apr 19, 2014 at 16:58
  • 1
    It won't work if you also filter by start or end date, because then it'll only use the start/end date of the first value.
    – TwoD
    Commented Jun 2, 2014 at 9:43
1

This worked for me in the Views field configuration for the Date field:

  1. Hide Repeat Rule
  2. In the "Multiple Field Settings" fieldset, remove the checkbox for "Display all values in the same row".
0

When in the views edit screen, make sure that you are displaying fields, and configure the date field in question to 'Hide Repeat Rule' and under 'Multiple Values' set it to show 1 value.

6
  • I do it but as soon as you sort by date "multiple values" option is ignored.
    – ozke
    Commented Feb 27, 2013 at 15:54
  • Make sure that you have un-checked 'Display all values in the same row' under 'Multiple Field Settings'.
    – Triskelion
    Commented Feb 27, 2013 at 16:09
  • I did. Still the same. Sorting by date = showing the event in all its multiple dates.If I don't sort by date then all great. So annoying! :S
    – ozke
    Commented Feb 27, 2013 at 19:45
  • OK. Let's try to drill down on this. I have been taking my suggestions directly from a working view: block display, un-formatted list of fields, no grouping, sorted by start date (I use an end date in the field) and filtered and restricted to show only 5 current and upcoming events. The only advanced setting is 'Do Not Cache'. What does your view look like? Can you notice any glaring differences?
    – Triskelion
    Commented Feb 27, 2013 at 20:34
  • Thanks for the interest in advance. Sorting by "start date" works just fine and does not create any duplicates. Sorting "by date" is the problem, it makes as many results as repeating dates no matter what I do. FYI... what I am trying to achieve is showing the next 5 incoming events. If one of the repeats of an event is one of the closest results then show only that repeat. Sorting by date should do that but there's this annoying buy. :(
    – ozke
    Commented Feb 28, 2013 at 9:35
0

this can also be achieved by going to views Advanced settings, under OTHER settings you will find Query settings just open it and check the "Distinct" option. Only single value will be shown.

1
  • No, that doesn't work if you sort by the date value.
    – user1731
    Commented Jun 29, 2015 at 7:07
0

I have been playing around with these settings and have stumbled upon an answer:

  1. In the View, under Advanced, mark the checkbox to Aggregate the results.
  2. In Advanced, under Query View, mark the checkbox for Distinct.
  3. Go back to your list of Fields, and click the Aggregation Settings and aggregate the distinct fields in the view.

I also removed the Filter Criteria for Date Delta, which I was trying (unsuccessfully) to use for creating distinct records.

Your Answer

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

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