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.
Comment | File | Size | Author |
---|---|---|---|
#4 | agenda-clone-multiday-events-2384721-4.patch | 5.15 KB | gooddesignusa |
#2 | agenda-clone-multiday-events-2384721-2.patch | 4.36 KB | gooddesignusa |
agenda_clone_multiday.png | 55.64 KB | gooddesignusa |
Comments
Comment #1
gooddesignusa CreditAttribution: gooddesignusa commentedComment #2
gooddesignusa CreditAttribution: gooddesignusa commentedComment #3
gooddesignusa CreditAttribution: gooddesignusa commentedAfter 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.
Comment #4
gooddesignusa CreditAttribution: gooddesignusa commentedNew 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']));
Comment #5
lukas.bernard CreditAttribution: lukas.bernard commentedThanks.
I tried your patch and is working, but it brokes translating of days and months: https://www.drupal.org/node/1273200
Comment #6
lukas.bernard CreditAttribution: lukas.bernard commentedTranslations 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?
Comment #7
gooddesignusa CreditAttribution: gooddesignusa commentedI will make a new patch later today. I also have to add some code to the install file. Thanks for testing.