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

Event Calendar Module - Upcoming Events from Multiple Calendars


Go to End


2 Posts   1235 Views

Avatar
VicfromPerth

Community Member, 8 Posts

17 July 2012 at 4:34pm

Hello

I have three event calendars on my site and I would like to display the upcoming events on the home page. The problem is, I can only get it to display events from my first calendar (but the calendar I want to use on the home page is not the first one).

I have tried in the template using

<% control UpcomingEvents(5, 'calendar') %>

and also
 <% control UpcomingEvents(5, calendar) %>

where my URLSegment is calendar, but it is still getting the events from the first calendar in the database.

Can anyone please help me with how I get it to show a different calendar?

Thank you
Vicki

Avatar
VicfromPerth

Community Member, 8 Posts

18 July 2012 at 2:30pm

in case anyone else is trying to work this out I wound up changing the upcomingEvents function called from my HomePage.php (mysite/code/HomePage.php) from:

function UpcomingEvents() {
		return DataObject::get_one("Calendar")->upcomingEvents(5);
	}

to
function UpcomingEvents() {
		return DataObject::get_one("Calendar", "URLSegment = 'calendar'")->upcomingEvents(5);
	}

If anyone has a better solution i would love to hear it as obviously if my client changes the URL this will no longer work.