A client wanted the agenda module to work like the google agenda display where multi-day events are rendered on each day until the event is finished.

I got this working by adding some code to agenda_group_events_for_block(). I added a bunch of comments to explain what each part of the code does. There might be a cleaner way to do this but this will get the ball rolling.

I don't update the actual event start time, just $event['when'] which is used for grouping.
Past events that are still ongoing will no longer render before the today group unless "Agenda start" is set to something like "-1 day"

It doesn't make sense to rerun this cloning every time agenda_group_events_for_block() is called so I save the grouped events to cache. I'm not sure if we really need 2 caches for each block. One for google response and one for grouped events. If this patch gets added to 7.x-2 maybe we only cache grouped events.

See the attached screen shot to see how the agenda block display changes when enabling this option.

Comments

gooddesignusa’s picture

Issue summary: View changes
gooddesignusa’s picture

gooddesignusa’s picture

After doing some more testing I found a bug where the event duration is calculated incorrectly. This happens with events span over to the next year. I discovered this issue when testing an event starting on 12-12-2014 and ending on 1-10-2015.

I will post a new patch shortly.

gooddesignusa’s picture

New patch fixes event duration calculation. Also include a couple lines I forgot in the first patch to clear the second cache.

This Patch Updates agenda-block.tpl.php
If you are using a custom tpl file in your theme you will need to update
$date = $day[0]['start date'];
to
$date = date($block->dateformat,strtotime($day[0]['when']));

lukas.bernard’s picture

Thanks.
I tried your patch and is working, but it brokes translating of days and months: https://www.drupal.org/node/1273200

lukas.bernard’s picture

Translations are OK, when you update agenda-block.tpl.php to:
$date = format_date(strtotime($day[0]['when']), 'custom', $block->dateformat, $block->timezone);
Could you update the patch to reflect this?

gooddesignusa’s picture

I will make a new patch later today. I also have to add some code to the install file. Thanks for testing.