Sorry if this has been covered elsewhere, I have looked around and can't find the answer anywhere.

Here's the question:

Is it possible on a day view to have a node column expand through it's FROM and TO times in a custom time grouping?

Here's the background:

I am creating a simple room booking system using calendar to show what rooms have been booked in a given day. Each room is a taxonomy term assigned to the booking content type I have created which uses a date field for "From" and "To" times. The Calendar day view has been given a custom Time grouping from 08:00:00 all the way down to 15:30:00 with half an hour increments between. The Field grouping has been set to the taxonomy term so I can see all the different rooms in one day view.

The problem is that the booking shows in the starting time slot, but does not extend down to the "To" time. So visually you can't see how long the room has been booked out for. Please see the attached images if you are unsure what I am referring to.

Is this something already present in Calendar? It seems to me since the calendar is a giant table it would require a great deal of rowspans to accomplish something like this which would probably get a little crazy. But I'm hoping it's already there and I just missed something. Thanks for the great module!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

arvinsingla’s picture

I've been messing around more with this issue and here's what I've found

Taking a look at the theming side of things with the template files. My thought was either using a rowspan (which I don't think would work) or simply colour in the other cells in the column up to the ending time (Seems like a better solution). So I was playing with what data is available to me in the templates and it looks like the "To" time has absolutely no correlation with Calendar whatsoever. The only place I have access to the data is if I specify it as a field that is printed. I have a feeling what I want to do cannot be done with the Calendar module in it's current state, and I have a feeling it has to do with the Date: argument in the view.

I'm hoping someone can prove me wrong. Surely I'm not the only one that can benefit from this use case.

NickSI’s picture

I've encountred same problem and end up with new calendar-day theme and new calendar day preprocess function. I have not tested it in all possibile options combinations, but it shows events spanned to multiple rows, properly handles grouping and all day events.
In order to give it a try:
1. Copy attached calendar-day.tpl_.php_.txt into your theme directory and rename it to calendar-day.tpl.php
2. Copy contents of preprocess_calendar_day.txt (this is template preprocess function) into your template.php file
3. Rebuild theme registry

Hopefull it will work. For me it works with 6.x-2.0-rc6

arlinsandbulte’s picture

Category: support » feature
Status: Active » Needs review
FileSize
63.92 KB

This would be a great feature to have... I would like it to work like Google calendar's day view...

webwriter’s picture

Subscribe. Need this functionality, also for a room-booking application.

ufku’s picture

Kudos to NickSI.
Using 6.x-2.2 and his solution is still working.
If made compatible with old(currently default) templates it could be the default for day and week views in future releases.

kreynen’s picture

Adding a comment describing this as Calendar View that adjust Event size based on event's duration by adjusting calendar-day.tpl and adding phptemplate_preprocess_calendar_day() function so other users don't have to learn the hard way that D.O. search of the issue queue does not return partial file name matches.

This works really well. Will likely include it in TVFrame and leverage it in both MERCI and Timeslot Scheduler.

Thanks NickSI!

arlinsandbulte’s picture

+1 - Need to check out the code in #2 to see how/if it works.
Sounds promising according to #5!

mautumn’s picture

The Holy Grail of Calendar! A nifty bit of inspiration and coding. Thank you very much indeed for this.

arlinsandbulte’s picture

Status: Needs review » Needs work

This had fallen off of my radar, but as GlossyIbis implies, would be a great addition to the calendar module.
Could someone create a proper patch for testing & commit?

sethhavens’s picture

subscribing

FreddieK’s picture

This is a great start. Without having digged into the code yet, is it possible to customize it to work for week views too?

arlinsandbulte’s picture

NOTE: I marked #648002: show events spanning multiple hours on calendar day view as a duplicate of this issue.
That issue does have some working code that might be merged with the efforts here.

joachim’s picture

Title: Show a node FROM/TO in Day View on custom Time Grouping? » show events with FROM/TO spanning multiple hours on calendar day view
Status: Needs work » Needs review
FileSize
18.12 KB

Changing the title of this so it's more easily findable -- I searched on 'span' when I was looking for existing issues on this.

Here's my patch from that other issue. It uses a different algorithm to fill up the columns:

- go down all the timeslots. for each slot, if there is a suitable item, add it there. if an item should span, skip subsequent timeslots.
- if there are unplaced items left over once you've done all timeslots, start a new subcolumn and repeat the process.

The subcolumns allow concurrent events to sit side by side as in this screenshot:

calendar-day-view-spanning.png

More work needed: some CSS wizardry is needed to make the item divs fill their table cells (though I gather this is pretty tricky; might need a jQuery hack), and it may be an idea to try to hide the subcolumn borders with CSS.
Also, I've not been able to actually test with multiple columns due to #389974: Field grouping in Calendar Day view, but the data structure is the same for one column so that should be okay.

eclauset’s picture

Subscribe

eclauset’s picture

I have calendar events that run for 24 hours in 2-3 hour chunks, starting at midnight -- so the first two events are 12-3am and 3-6am. The patch in #2 displays the first event as 12am to 4am, overlapping with the 2nd item, and so on for each consecutive item.

I wanted it to display correctly without having to set each event's end time to x:59
so after this line in template.php:
$event_end = $event->calendar_end_date->format('H:i:s');

I added this line, to subtract 1 second from the end time of each event:
$event_end = date('H:i:s', strtotime('-1 second', strtotime($event_end)));

Has anyone gotten this working with the week view yet?

texas-bronius’s picture

For anyone checking this out-- it works :) Here is the "out of the box" of what adding @NickSI #2's template overrides provides. Good stuff.

Aceman’s picture

Good work! This was exactly what I was looking for!
I'm trying to convert it for the week view too, but I'm not having so much luck.
Has anyone already done it? I've created a calendar-week.tpl.php file and added a new function in the template.php file but it's not working.

jimurl’s picture

Aceman-

I am also working on a week view, and I tried the same thing- I renamed the function phptemplate_preprocess_calendar_day to ....._calendar_week, and put a customized calendar-week.tpl.php into my template folder with the weekified version of the code in this calendar-day.tpl.php file. But it didn't work. I will need to dig into it further, and will post my results here (unless somebody else gets to it first.)

gorgo’s picture

Hi,
I've tried NickSI's code and it works pretty good!
I am however having 2 problems with it, and I'm hoping NickSI or somebody else here would be able to help me with:

1. I can only view 3 events at the same time. (example: event 1 10:00-13:00, event 2 - 11:00-15:00, event 3 - 9:00-11:00. now if I add event 4 - 8:00-11:00, event 1 will disappear from the view. if I add event 5, event 2 will be gone and so on...)
2. Event's start and end times don't show properly. (example: if an event starts at 10:00 and ends at 12:00 it appears fine, but if it starts at 10:30 and ends at 11:45, it still appears as if it starts at 10:00 and ends at 12:00)
3. Is there a way to set it up so that the day doesn't start at 0:00?

Kind regards,
Guy

developer-x’s picture

Hi,

I just discovered this issue. I've submitted a patch that provides multi-day theming support to the calendar module at http://drupal.org/node/931392. I was planning on tackling multi-hour span for day/week next - but I see there is already some work on this. I don't want to recreate the wheel here - but I had a particular plan of attack in mind - which would build off my multi-day patch. In particular, the hour/half-hour slots would be of a defined height. The table would be a position of relative. The divs which encapsulate the events would have an absolute position and be assigned a class in the multiple of the time unit(half hour) and a class based of it's enumeration within the timeslot. These class would provide for spanning, layering and staggering . So, something like:

<div class='unit3 item2'>Some event</div>  

would give the event 3 height-units, 2 offset-units and z-index of base+2.

Does the patch in this issue take this approach? Would anyone be interested if I tried to extend my multi-day patch with either the patch in this issue or pursue my own strategy?

- x

developer-x’s picture

FileSize
68.09 KB

I've implemented a solution for displaying events spanning multiple hours, as well as, concurrent events. I generally used the strategy as outlined in the previous post. For those interested, you can apply the patch from here : http://drupal.org/node/931392#comment-3611920

I've uploaded a screenshot and you can view a demo of the functionality here : http://www.okeel.com/demo/calendar/2010-W42

globetrotter’s picture

subscribing

azlara’s picture

Hi, I tried the @NickSI #2's solution with Calendar 6.x-2.4 but it's not working, I did exactly what he says but I got the next message: "warning: Invalid argument supplied for foreach() in sites/all/modules/calendar/theme/calendar-day.tpl.php on line 44."
the "phptemplate_preprocess_calendar_day" function is not setting the "$header_columns" variable, that's way it fails, could anyone post the solution of this problem? Any help would be appreciated.

Steel Rat’s picture

I'm getting this error as well. I suspect it's a PHP4/5 issue.

Neslee Canil Pinto’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

The D6 branch is no longer supported so we're closing this issue. If you think this issue still exists in D7 you can open a new one.