Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar Module - Upcoming Events from Multiple Calendars

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 451 Views
  • VicfromPerth
    Avatar
    Community Member
    8 Posts

    Event Calendar Module - Upcoming Events from Multiple Calendars Link to this post

    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

  • VicfromPerth
    Avatar
    Community Member
    8 Posts

    Re: Event Calendar Module - Upcoming Events from Multiple Calendars Link to this post

    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.

    451 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.