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.

All other Modules

Discuss all other Modules here.

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

Event Calendar Module - Upcoming Events from Multiple Calendars


Reply

2 Posts   476 Views

Avatar
VicfromPerth

17 July 2012 at 4:34pm Community Member, 8 Posts

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

18 July 2012 at 2:30pm Community Member, 8 Posts

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.