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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Return Events only (not announcements) from EventCalendar


Go to End


3 Posts   1025 Views

Avatar
NickJacobs

Community Member, 148 Posts

1 June 2010 at 10:50am

Hi, I'm trying to return a list of upcoming main events (excluding announcements) from the EventCalendar. I only want to display events where there is an actual CalendarEvent page....

Is there a simple way to do this using the Calendar built in functions?

Cheers
Nick

Avatar
UncleCheese

Forum Moderator, 4102 Posts

1 June 2010 at 11:36am

Hi, Nick,

Check the UpcomingEvents function in Calendar.php.. at least one of the arguments is a filter (there may even be two).. Anyway, you want to apply one like "is_announcement != 1", and that should work for you.

Avatar
NickJacobs

Community Member, 148 Posts

1 June 2010 at 12:12pm

Edited: 01/06/2010 12:12pm

Hi UC,

yeah there are two arguments in that function, but I've tried a few variations and I either get errors or no result....

this works (but doesn't give me access to any calendar functions):

function getHomeFeatureEvents(){
return DataObject::get("CalendarDateTime","StartDate >= DATE(NOW()) AND is_announcement!=1","StartDate ASC","",5);
}

but this doesn't:

return DataObject::get_one("Calendar")->upcomingEvents(5,"is_announcement != 1"); 
{/code]