Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

event calendar: get all future events


Go to End


3 Posts   1507 Views

Avatar
marcink

Community Member, 89 Posts

22 April 2009 at 7:02am

hi,

hi, how can i get all future events?
i'm not in the calendar scope, so i try with this code:

$var = DataObject::get("CalendarDateTime", "StartDate > " . date("now"));

but it doesn't work...

thanks

Avatar
marcink

Community Member, 89 Posts

22 April 2009 at 7:37am

never mind, just found out:

$now = date("Y-m-d");
$var = DataObject::get("CalendarDateTime", "StartDate > '$now'", "StartDate");

Avatar
UncleCheese

Forum Moderator, 4102 Posts

22 April 2009 at 9:35am

That's not the best way to do it because you'll only get CalendarEvent objects rather than announcements and recurring events as well. Use:

DataObject::get_one("Calendar")->upcomingEvents(5);

Where the first argument is the number of events to return. Also see Calendar::recentEvents();