Log in

View Full Version : How do I put calendar events in chronological order?


RobinPriestley
03-15-2006, 03:58 PM
Hello All,

Sorry to duplicate, this is in another place too, but this seems to be the best forum for it.

I would like to know how to make my calendar events appear in chronological order within a day. At the moment they seem to turn up in the order that I input them, as opposed to the order they happen. For example today I have:

Wednesday 15
19:45 King Kong
14:40 The New World
17:45 Wallace & Grommet Curse of the Ware Rabbit
13:00 Corpse Bride

I guess that an "ORDER by dateline_from" bit in the MySQL query that makes today's events would sort it out, but I don't know where (or how) to do this.

If anyone could help it would be really really appreciated.

Thanks in advance.

Thoki
07-12-2006, 09:25 AM
Found it:
Open ./includes/functions_calendar.php and search:

$events = $vbulletin->db->query_read("
SELECT event.*,
user.username, IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid,
IF(dateline_to = 0, 1, 0) AS singleday
" . iif($vbulletin->userinfo['userid'], ", subscribeevent.eventid AS subscribed") . "
FROM " . TABLE_PREFIX . "event AS event
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = event.userid)
" . iif($vbulletin->userinfo['userid'], "LEFT JOIN " . TABLE_PREFIX . "subscribeevent AS subscribeevent ON (subscribeevent.eventid = event.eventid AND subscribeevent.userid = " . $vbulletin->userinfo['userid'] . ")") . "
WHERE calendarid = $calendarinfo[calendarid] AND
((dateline_to >= $beginday AND dateline_from < $endday) OR (dateline_to = 0 AND dateline_from >= $beginday AND dateline_from <= $endday )) AND
visible = 1
");
// Cache Events

?ndert das in:

$events = $vbulletin->db->query_read("
SELECT event.*,
user.username, IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid,
IF(dateline_to = 0, 1, 0) AS singleday
" . iif($vbulletin->userinfo['userid'], ", subscribeevent.eventid AS subscribed") . "
FROM " . TABLE_PREFIX . "event AS event
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = event.userid)
" . iif($vbulletin->userinfo['userid'], "LEFT JOIN " . TABLE_PREFIX . "subscribeevent AS subscribeevent ON (subscribeevent.eventid = event.eventid AND subscribeevent.userid = " . $vbulletin->userinfo['userid'] . ")") . "
WHERE calendarid = $calendarinfo[calendarid] AND
((dateline_to >= $beginday AND dateline_from < $endday) OR (dateline_to = 0 AND dateline_from >= $beginday AND dateline_from <= $endday )) AND
visible = 1
ORDER BY dateline_from
");
// Cache Events


HP! :-)

--
Thoki

RobinPriestley
07-13-2006, 02:10 PM
Thanks a bunch that is perfect, it works a treat! :)

hardfm
07-15-2006, 08:02 AM
i also had this problem, only this code does not work perfect for me :(
this is becouse we have Recurring Event that start/end with different
dates. so
event1 is from jan 10th till feb 10th - 6pm till 8pm
event2 is from jan 20th till feb 20th - 4pm till 5pm
event3 is from jan 5th till march 30th - 5pm till 6pm

on this way it shows always event3 first, then event1 and as last event1 (when the events are recurring every x day)

so the question is actualy if its possible to sort the events by the time/hour on the day of the event.

Thoki
07-16-2006, 06:26 AM
hardfm,
you´re right. With recurring events this "quick hack" doesn´t work.
But I´m not the expert.
May somebody help us with this problem?

--
Thoki