Closed (won't fix)
Project:
Event
Version:
5.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Apr 2007 at 13:39 UTC
Updated:
2 Dec 2007 at 19:37 UTC
Hello,
I was wondering if it were possible to display events like this:
I am absolutely in love with LWN's calendar view. It could be simplified, so that every event would just display a line if it's covering something that is not the first or the last day. HOWEVER, an event would need to always be in the same spot vertically, or the lines would be broken. Now, this would be tricky.
Is this kind of view achievable with the event module in your opinion?
Bye,
Merc.
Comments
Comment #1
gerhard killesreiter commentedLooks very nice indeed. I am not sure this can be achieved with the event module, though.
Comment #2
BachusII commentedI think it can be done. Bare with me, this could be tedious.
First, look at 63239 replies #1 & #2. Those should give an idea on how to style a line such as requested. (All except the vertical alignment at least.)
Now, for the vertical.
Currently in event module each week is one tablerow high. If we know how many events there are in a given week and each day in it. (We can get those numbers, can't we?). We could use as many rows as we want/need for each week. That's how lwn.net seems to do it.
Add a classname to the first row, and to the last row to style any borders and extras we want, Not forgetting to add the daynumber to the cells in the first row of course.
Sorting the single day events first, (they don't bite each other) and put them in the first row. Place multiple day events in subsequent rows. (Naturally not leaving the first row empty if there are no single day events.)
All we need next is a good sorting algorithm to blend them in as little rows as we can. And that will be the hard part I think.
I'll try to mock something up on the server/markup side. Styling will be your own task.
Comment #3
BachusII commentedOh boy, this would require a major rewrite of the module.
What happens now is that a calendar (week/month/day/whatever) is created, the module loops through each cell (representing a date) and drops whatever related events in that cell.
What's needed is a data model that gets filled with events (quite possibly using the approach above) which then gets parsed to create an appropriate table structure.
That would mean a bump in version. I'm all for it in principle cause it would create a great many effects possible.
If the event module developers want to go this route, I'm willing to pitch in.
Comment #4
micheleannj commentedThis is what I need for my site as well; users will be adding multi-day events and the current repeating display just isn't going to scale.
I'm happy to help test and/or contribute code where I can...
thanks
maj
Comment #5
mightyiam commentedPerhaps ask them for the code?
Comment #6
mercmobily commentedHi,
I will ask them for the code. But, they tend not to respond to emails.
Plus, I am pretty sure their code in in Python...
Doing it now.
Merc.
Comment #7
michelleComment #8
mercmobily commentedHi,
Good news: I have spoken to the LWN guys, and they are gonna send me the code soon (!).
I can't wait. I hope somebody here knows both Python and php... because I can't really read Python! :-D
Merc.
Comment #9
killes@www.drop.org commentedOk, I think I've come up with a solution on how you can do this with event module:
you need to override function theme_event_node_month($node) in your theme.
A node passed to this function will have one of a couple of states. $node->event['state'] can have the values "start", "ongoing", and "end", among others. All you need to do is to print the date and the |-sign if the state is "stat", print "--", if it is "ongoing" and -|" if it is end.
Comment #10
mercmobily commentedKilles: sorry to be a pain and reopen this, but...
One of the other problems is that an event needs to stay in the same row as when it started. So, if Monday there are for events (A, B, C, D) and on Tuesday event B ends (whereas everything else continues for the whole week):
* On Monday you have 4 events:
-----
A
B
C
D
-----
* On Tuesday you have four events
---
A
B (ends)
C
D
---
Then, on Wednesday, you have three events, but an empty "space"!
---
A
(empty space)
C
D
---
If you don't, you cannot guarantee (with HTML) that the horizontal lines for the events C and D will be continuous. So, on Wednesday the line for "C" will "break", because C will end up on a different height.
The change to the module, though, should be rather trivial: when a new event is found (and that's easy enough), it gets allocated a number (1 to 10, I assume), as low as possible. When an event ends, it "releases" that number. Then, the theme should consider the "number" to know which slot the event should be in.
Does this make sense? I haven't seen the code - would this be hard to do? (If the answer is "no", I might give it a go - even better, please direct me in the source file :-D )
DOes anybody here know CSS well enough so that my efforts would be "rewarded" with a decent look?
Bye!
Merc.
Comment #11
mercmobily commentedHi,
I had a closer look at the code.
The crucial for is the one at line 1045 in event.module:
for ($x = ($first > $node_start ? $first : $node_start); $x < $last; $x += 86400) {
THis could actually he hacked quite nicely. I could write a function called "event_reserve_slot", which has a STATIC array of 15 spots, and returns the next available slot. Also, event_free_slot simply frees a spot.
SO, it would have something like:
if (gmdate('m', $x) == $month) {
if ($x == $node_end) {
$nid->event_state = 'end';
event_free_slot($nid->event_slot ) **************;
$data[$year][$month][gmdate('j', $x)][] = $nid;
$x = $last + 1;
}
elseif ($x == $node_start) {
$nid->event_state = 'start';
$nid->event_slot = event_get_slot(); ************
$data[$year][$month][gmdate('j', $x)][] = $nid;
}
Killes: do you think it could work?
Merc.
Comment #12
killes@www.drop.org commentedI've plyed around a bit with your idea. One problem is that if you have say on monday a singleday event and a multiday event starting. On the rest of the week you only have this multidy event. How would you alocate the slots? Should the multiday event on Tue-Fri be in slot 1 or 2?
Comment #13
mercmobily commentedIn this case, if on monday the single-day event was allocated to slot 1, and the multiday event was allocated to slot 2, then tue-fri the multi-day event will need to stay in slot 2, so that the line can be a continuous one!
I *think* my proposal would work with that - right?
Comment #14
killes@www.drop.org commentedThe problem is that we'd need to put a bogus event into slot 1 for Tuesday etc, if I am not mistaken. If you look at the generated html in a calendar you will see what I mean.
Comment #15
mercmobily commentedHi,
Ugh, I think you are totally right.
But. this would mess up things a bit, I assume.
Or maybe having an empty event wouldn't be such a big problem?
What do you thin killes?
Merc.
Comment #16
killes@www.drop.org commentedUnfortunately, I think it would be a problem. An empty event wouldn't have a start time, a title, anything. This would break many of the default theme functions. And I don't think that adding if/then checks in the theme layer would be an option.
Comment #17
killes@www.drop.org commentedseems this isn't really possible with the current calendar rendering code.