I'm trying to show upcoming events, including announcements, on a home page. I've found a few old threads about this, but those solutions no longer work. For one thing is_announcement is no longer a field in the CalendarDateTime table. It looks like the UpcomingEvents function in Events Calendar 3 should grab announcements by default, but I'm not getting any.
Also, $EventTitle and $_Dates no longer work in templates. $Title and $DateRange are working for me in their place.
As far as pulling announcements, I've got the first function below in my Page_Controller class. It works for pulling events, but not announcements.
public function MyUpcomingEvents($numEvents=5) {
return DataObject::get_one("Calendar")->upcomingEvents($numEvents, );
}
I tried this version from the older threads. It throws an error and the page won't load at all.
public function MyUpcomingEvents($numEvents=5) {
return DataObject::get_one("Calendar")->upcomingEvents($numEvents, "is_announcements = 1");
}
This version does the same as the first, loads events only, no announcements.
public function MyUpcomingEvents($numEvents=5) {
return DataObject::get_one("Calendar")->upcomingEvents($numEvents, "(CalendarDateTime.ClassName LIKE 'CalendarAnnouncement' OR CalendarDateTime.ClassName LIKE 'CalendarDateTime')");
}
This is what I have in my HomePage.ss
<% control MyUpcomingEvents(5) %>
<% if Event %>
$DateRange
<a href="{$Link}" title="More Details about {$Title}">$Title</a>
<% end_if %>
<% end_control %>
Any ideas how I can get announcements ?
Thanks,
Cathy