10446 Posts in 2223 Topics by 1719 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1001 Views |
-
Calendar events on homepage not showing today's ICS events

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! -
Re: Calendar events on homepage not showing today's ICS events

8 January 2010 at 11:25am Last edited: 8 January 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!
| 1001 Views | ||
|
Page:
1
|
Go to Top |

