Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Calendar events on homepage not showing today's ICS events

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1167 Views
  • coffeymachine
    Avatar
    Community Member
    10 Posts

    Calendar events on homepage not showing today's ICS events Link to this post

    Hi,

    I have successfully gotten my calendar events to display on the home page with this code in my HomePage controller:

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

    The problem is ICS events scheduled for TODAY won't show up, even though they display as expected on the calendar page. All the other events work fine too.
    Any help would be appreciated. Thanks!

  • coffeymachine
    Avatar
    Community Member
    10 Posts

    Re: Calendar events on homepage not showing today's ICS events Link to this post

    Okay, I figured this one out myself. It only took me 3 days!

    In my HomePage_Controller class in mysite/code/HomePage.php I put the function

    public function Events() {
    $today = date("Y-m-d");
    return DataObject::get_one("Calendar")->Events(null, $today, null, false, 5, null);
    }

    Then in my templates/Layout/HomePage.ss file:

    <% control Events %>
       <li>
          <h5>$EventTitle</h5>
          <span>$_Dates</span>
       </li>
    <% end_control %>

    The trick was to pass today's date to the Calendar class' function, because for some reason it was not getting the correct date for today to read the ICS feeds.
    I hope this helps somebody!

    1167 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.