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, biapar, Willr, Ingo, swaiba, simon_w

Event Calendar - error when trying to list all events sorted by start date


Reply

2 Posts   634 Views

Avatar
ayyurek

4 May 2011 at 6:58am (Last edited: 4 May 2011 7:00am), Community Member, 41 Posts

I am having some problems about event calendar module. I hope someone can help :)

I extended the Calendar class,

class ExhibitionHolder extends Calendar
{
   static $has_many = array (
      'ExhibitionPages' => 'ExhibitionPage'
   );
}


and,
CalendarEvent class.

class ExhibitionPage extends CalendarEvent
{
   static $has_many = array (
'ExhibitionDates' => 'ExhibitionDateTime'
   );
}

In the ExhibitionHolder.ss I want to list 5 upcoming events if there are no dates clicked.

<% if Events %>
<% control Events %>
$_Dates $EventTitle $Link
<% end_control %>
<% else %>
<% control ExhibitionList %>
$Title <% control Dates %>$StartDate.Nice<% end_control %> <% control Dates %>$EndDate.Nice<% end_control %> $Link
<% end_control %>
<% end_if %>

The following function returns the list of all Exhibition Pages as expected. But I when I try to sort them using StartDate. I get error. When I use ID in the join, I get error 'Column 'ID' in on clause is ambiguous'. When I use ExhibitionPage.ID, I get error 'Unknown Column ExhibitionPage.ID'.

function ExhibitionList($num=5) {
   return DataObject::get("ExhibitionPage", "", "CalendarDateTime.StartDate ASC", "LEFT JOIN CalendarDateTime ON CalendarDateTime.EventID = ID", $num);
   }

Any help will be great.

Avatar
ayyurek

4 May 2011 at 7:17am Community Member, 41 Posts

Ok, it was an unnecessary problem. Events module shows the upcoming events by default, in the calendar home page. I couldn't see them because it's listing only events for upcoming 6 months. And I was having events for 2012. You can change 6 months to anything you want in the Calendar.php file line 41.

static $defaultFutureMonths = 6;