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

Calendar events on homepage not showing today's ICS events


Go to End


2 Posts   1992 Views

Avatar
coffeymachine

Community Member, 10 Posts

6 January 2010 at 10:33am

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!

Avatar
coffeymachine

Community Member, 10 Posts

8 January 2010 at 11:25am

Edited: 08/01/2010 11:28am

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!