10446 Posts in 2223 Topics by 1719 members
| Go to End | ||
| Author | Topic: | 1422 Views |
-
Re: [Solved] Event Calendar - show past events

4 March 2011 at 6:50am
Another question:
when using control children, the events aren't sorted by event date, but by pagetree position.
I need a function that gets all events from the past year:
public function ShowAllEventsPlease() {
$startdate = date('Y-m-d', strtotime(date('Y-m-d') . " - 1 year")));
return DataObject::get_one("Calendar")->Events(null, $startdate, null, false, 9999, null);
}but now i get a code error, whats the correct code?
-
Re: [Solved] Event Calendar - show past events

4 March 2011 at 8:16am
Try this:
$startdate = sfDate::getInstance()->previousYear()->firstDayOfYear();
$enddate = sfDate::getInstance()->previousYear()->finalDayOfYear();
return DataObject::get_one("Calendar")->Events(null, $startdate, $enddate, false, 9999, null); -
Re: [Solved] Event Calendar - show past events

4 March 2011 at 11:02am
Hmm to bad!
i get error:
Fatal error: Class 'sfDateTimeException' not found in /public/sites/url/event_calendar/code/sfDate.class.php on line 244
Another idea?
-
Re: [Solved] Event Calendar - show past events

5 March 2011 at 3:47am
Maybe it's subtractYear().. I don't remember. You can look at the API.
-
Re: [Solved] Event Calendar - show past events

7 March 2011 at 5:22am
This works to show all past & future events!
public function ShowAllEventsPlease() {
$startdate = sfDate::getInstance()->subtractYear(1)->firstDayOfYear();
$enddate = sfDate::getInstance()->addYear(6)->finalDayOfYear();
return DataObject::get_one("Calendar")->Events(null, $startdate, $enddate, false, 9999, null);
}
| 1422 Views | ||
| Go to Top |
