Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » event calendar: get all future events

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1078 Views
  • marcink
    Avatar
    Community Member
    89 Posts

    event calendar: get all future events Link to this post

    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

  • marcink
    Avatar
    Community Member
    89 Posts

    Re: event calendar: get all future events Link to this post

    never mind, just found out:

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

  • UncleCheese
    Avatar
    4085 Posts

    Re: event calendar: get all future events Link to this post

    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();

    1078 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.