10386 Posts in 2198 Topics by 1712 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 223 Views |
-
EventCalendar 3 - Loading announcements with UpcomingEvents()

6 November 2012 at 3:35pm
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 -
Re: EventCalendar 3 - Loading announcements with UpcomingEvents()

13 November 2012 at 4:30pm
Thanks to Bstarr in this thread -
http://www.silverstripe.org/all-other-modules/show/17306I changed the code in the HomePage.ss template to the following and the first function is now working.
<% if Announcement %>
$DateRange
<a href="{$Link}" title="More Details about {$Title}">$Title</a>
<% else %>
<% if Event %>
$DateRange
<a href="{$Event.Link}" title="More Details about {$Event.Title}">$Event.Title</a>
<% else %>
No events to display
<% end_if %>
<% end_if %>
| 223 Views | ||
|
Page:
1
|
Go to Top |

