I wanted to ask how I can group events by day in a view.

It works fine if I only have events that have their start- and endtime on the same day.
2011-04-12
2011-04-12 10:00 – 2011-04-12 18:00 Event 1
2011-04-12 12:00 – 2011-04-12 14:00 Event 2

2011-04-13
2011-04-13 10:00 – 2011-04-13 18:00 Event 5
2011-04-13 12:00 – 2011-04-13 14:00 Event 8

The problem: I have some events that take several days or weeks.
Example: I create one event with the start date of 2011-04-12 10:00 and the end date of 2011-04-15 19:00 for example.

This event now shows up in the grouped view as
2011-04-12 - 2011-04-18
2011-04-12 10:00 - 2011-04-15 19:00 Event 11

I would like to have that event sorted into the regular day groups (split that event into day parts):
2011-04-12
2011-04-12 10:00 - 2011-04-15 19:00 Event 11

2011-04-13
2011-04-12 10:00 - 2011-04-15 19:00 Event 11

2011-04-14
2011-04-12 10:00 - 2011-04-15 19:00 Event 11

2011-04-15
2011-04-12 10:00 - 2011-04-15 19:05 Event 11

Similar to how it is done in the calendar – day view. But with a simple text list format.
I can not find a way to do this? Perhaps someone can give me a little help?

Comments

Joe_Acc’s picture

I am also interested how this can be done.
~ I have a view with events grouped by day
~ I want to show multiday* events on every day they take place (*multiday events are events that have one date group, where some days are between the from and the to date)

At the moment the multiday events are only shown once (according to the used day format either on the from-date or the to-date). How can I show them on all days.
This is possible with the calendar-module (but I do not like the calendar layout - I need a list or table). So this must be possible somehow with views also. But how ??? ??? ???

jenna.tollerson’s picture

Subscribing. I'm trying to make this happen too.

Dmitri-83’s picture

I would also like to know how to do this.
This is a *must* for every calendar listing.

Perhaps one of the developers of date can help us?

altparty’s picture

I'm very interested too.

marktheshark’s picture

Has anyone had luck setting an all day event?

I have a date with granularity down to minute, but I'm forced to enter the time in minutes every time.

It will not allow all day events that span multiple days.

tonytosta’s picture

I found this thread looking for an easy answer to this question. But since there was no answer, I made a little snippet that turned $rows into $grouped_rows. I was able pull the day without the time easily (I am using the 'Date' field type) with an explode. After that, I just organized the rows by the day.

<?php
/**
 * @file views-view-list.tpl.php
 * Default simple view template to display a list of rows.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $options['type'] will either be ul or ol.
 * @ingroup views_templates
 */
  $results = $view->result;
  $count = 0;
  foreach ($rows as $id => $row) {
    // Get the date without the time
    dsm($results[$count]->node_data_field_date_field_date_value);
    $datetime_parts = explode('T', $results[$count]->node_data_field_date_field_date_value);
    $day = $datetime_parts[0];
    dsm($day);
    $grouped_rows[$day][] = $row;
    $count++;
  }

?>
<div class="item-list">
  <?php if (!empty($title)) : ?>
    <h3><?php print $title; ?></h3>
  <?php endif; ?>
  <<?php print $options['type']; ?>>
    <?php 
      // replace the old $rows handling with support for $grouped_rows
      foreach ($rows as $id => $row) {
         echo '<li class="'. $classes[$id] .'">'. $row .'</li>';
      }
    ?>
  </<?php print $options['type']; ?>>
</div>
mgorla’s picture

Anynone solved this?

I'd like to make a views of "next 5 days events" but it's almost impossible to achieve a good result if the multi-day events only show in the first day only :)

areikiera’s picture

Really interested in a solution to this also! A D7 solution would be very helpful.

wotaber’s picture

+1 subscribe

johnny5th’s picture

Issue summary: View changes

I reposted this issue on Stack Exchange and got an answer back.
http://drupal.stackexchange.com/questions/120378/grouping-by-day-events-...

The answer was from tenken:

Make 2 or 3 computed view fields (which will require some php):

1field for day of event
1 or 2 fields for start time and end time dates.
You can group the View output by the first field. Then create the event time range by inlining the 2 other fields.

With these 3 pieces of info the calendar should be able to see the start and end datetimes and make a line representing the event duration.

I created these two computed fields and posted the code on Gist. Hope this helps someone!

Computed Date Field
Computed Time Field

These are the value part of the computed field. They output a unix timestamp. You can change the output to whatever you want.

In my case, I used ViewsPHP to output the desired display, since I needed multiple versions of the display for grouping reasons.

The only issue with this method is you cannot use any of the Date contextual filters, filters, or pagers. But the output is essentially what needs to be ported to the Date module, in my opinion.

cwahlfeldt’s picture

Hey +johnny5th,

Thanks for creating that code but I seem to be at a loss for how to achieve the functionality that was asked for.

I managed to create the computed fields for each node that has the date field and then I reference that field in my view and group the view output by that field. But it doesn't group them together for every day occurrence on multi day dates (if that makes sense?).

Any Idea how this would effectively work for the original question? (I know its been a year since you commented but I'm hoping you still know hehe)

Thanks!

johnny5th’s picture

I'm sorry, cwahlfeldt, I don't remember how I got it working. I remember ditching the method due to the inability to use contextual filters or pagers.
Make sure you strip tags on the fields or disable the RDF module for grouping to work (if that's an issue at all). RDF adds extra markup to the output, which has caused me pain in the past with grouping.

cwahlfeldt’s picture

Thanks for the quick response, I guess ill take this to stack exchange.

DamienMcKenna’s picture

Status: Active » Closed (outdated)

We're sorry but the D6 release of Date module is no longer being supported. You are encouraged to update to Drupal 7 or 8, or direct questions to Drupal Answers.