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

event calendar - listing upcoming events


Go to End


2 Posts   882 Views

Avatar
thomas.paulson

Community Member, 107 Posts

22 January 2014 at 1:29am

Edited: 22/01/2014 1:30am

I am trying to listing upcoming events in footer.ss file. Below is code i am using, Unfortunately it list only recurring CalendarEvent,

/**
* Class EventsControllerExtension
*/
class EventsControllerExtension extends Extension
{
/**
* @param $limit
* @return mixed
*/

public function MyUpcomingEvents($limit){
//Debug::show(Calendar::get()->first()->UpcomingEvents($limit));
return Calendar::get()->First()->UpcomingEvents($limit);
}

}

-- config.php --
--------------------------------

if (class_exists('ContentController')) {
Object::add_extension('ContentController', 'EventsControllerExtension');
}

--- footer.ss ---------
------------------------

<ul>
<% loop $MyUpcomingEvents(2) %>

<li>
<h5>
<a href="$Link" title"$Title">$Title - $StartDate</a>
</h5>
$Content.FirstParagraph
</li>

<% end_loop %>

</ul>

Could somehelp me to list both non-recurring and recurring events.

Avatar
thomas.paulson

Community Member, 107 Posts

24 January 2014 at 4:21pm

Edited: 26/01/2014 4:32pm

oops, i have not set end date for the non recurring events. :D

Events are listing in footer now. Thanks Uncle Cheese for calendar event.