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.

All other Modules /

Discuss all other Modules here.

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

Use Event Calendar module in Includes for custom sidebar

Go to End

6 Posts   1528 Views


Community Member, 23 Posts

27 April 2010 at 10:43pm

I've installed the Events Calendar module, which is working fine. The site I'm building has various items such as a booking form and events diary which are included in the sidebar. I need have an include which displays the $MonthNavigator with a set amount of upcoming events under it which I can include on any page that required it throught the site.

Does anyone know how this can be achieved?


Forum Moderator, 4102 Posts

28 April 2010 at 1:45am

The functions UpcomingEvents(), RecentEvents(), CalendarWidget() and LiveCalendarWidget() are all decorated into your SiteTree class, so you can call them anywhere. MonthNavigator() was not, but I have added it into the trunk (2.4 only).

It's easy enough to do it yourself, though..

return new MonthNavigator($your_calendar_object, new sfDate());


Community Member, 23 Posts

28 April 2010 at 9:12pm

Thanks for the reply. But I still can't seem to acheive what I'm looking for.

In my Page_Controller in Code/Page.php i have

function EventsDiary(){
MonthNavigator($(this), new sfDate());

and in my includes/ I have


This displays the drop down box, but tried to redirect me to another page. I wan't to be able to select a month and it show me events in that month inside my sidebar, I've attached a png of what I'm trying to acheive.


Attached Files

Forum Moderator, 4102 Posts

29 April 2010 at 1:27am

Edited: 29/04/2010 1:28am

This is not PHP syntax:


That's jQuery.

Your function isn't returning anything.

public function EventsDiary(){ 
return new MonthNavigator($this, new sfDate()); 

But if you're going to have this globally accessible, you can't use $this, because you don't know what page you're going to be on. So you need to pass it an object of the calendar you want to use.

DataObject::get_one("Calendar") for instance.. or whatever you're using.


Community Member, 56 Posts

29 April 2010 at 10:29pm

When including lists of events its useful to be able to filter which ones will appear through the cms. This can be done by changing getEventIds() to the following;

protected function getEventIds()
$ids = array();
if($children = $this->Children()) {
foreach($children as $child)
$ids[] = $child->ID;
return $ids;
// 'I dont trust you with my children'
//or joined if($children = DataObject::get("SiteTree", "ParentID='".$this->ID."' AND ShowInSearch=1","Created")) {
$sqlQuery = new SQLQuery("ID","SiteTree","ParentID='".$this->ID."' AND ShowInSearch=1");
foreach($results as $child)
$ids[] = $child['ID'];
return $ids;
} else {
return false;

Can something like this be put into the next release?


Forum Moderator, 4102 Posts

30 April 2010 at 2:01am

That whole function is ugly. I can't see how getEventIDs() would make it into the next release in any form. It's just bad practice.