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

EventCalendar - Individual event list on homepage


Go to End
Reply


9 Posts   1579 Views

Avatar
seah0rse

Community Member, 5 Posts

3 December 2012 at 10:02am

Hi,

I am trying to display a list of upcoming events and announcements on a homepage. I can display all events and announcements for multiple calendars by using the rss feed option combo. But I do not want to do that as I would like to list each calendars title and then a list underneath.
eg
Seniors events (cal name)

  • event 1
  • announce 1
  • event 2
  • announce 2

Masters events (cal name)
  • event 1
  • announce 1
  • event 2
  • announce 2

I have the following functions in my homepage controller
public function SeniorEvents() {
$where = "ParentID = 23";
return DataObject::get_one("Calendar")->upcomingEvents(10, $where);
}

public function AllCalendars() {
return DataObject::get('Calendar');
}

The last method lists each calendar but I cant get the events and I get an error if i try to call the upcoming events on the datalist..
The first function always pulls the data from the first calendar it comes across even if i use the filter clause.
Here is the where clause WHERE ("Recursion" = '1') AND ("ParentID" = '24') AND (ParentID = 23) AND ("SiteTree_Live"."ClassName" IN ('CalendarEvent')) ORDER BY "SiteTree_Live"."Sort" ASC,256) Calendar id 24 is always in the clause. If I use the template to pass the url frag to the function this does not appear to do anything..

If anyone can help me I appreciate it..
Also one other thing there is an incomplete url formed with any announcements listed via the upcoming events method...
announcement url = http://localhost/site/?date=2013-01-05
event url = http://localhost/site/surf-sports/surf-boat-rowing/senior-calendar/event-name/

Many thanks in anticipation.. (Uncle Cheese...help please)

cheers Tim

Avatar
seah0rse

Community Member, 5 Posts

3 December 2012 at 10:11am

Edited: 07/12/2012 10:38am

oops forgot...

If I do this in my AllCalendars template then I get close to what I am after nut no announcements and no dates.. :-(

<h4>All Calendars</h4>
<ul>
<% control AllCalendars %>
<li>$ID <a href="{$Link}" title="More Details about {$Title}">$Title</a></li>
<ul>
<% control children %>
<li>$ID $DateRange<a href="{$Link}" title="More Details about {$Title}">$Title</a></li>
<% end_control %>
</ul>
<% end_control %>
</ul>

Avatar
UncleCheese

Forum Moderator, 4096 Posts

6 December 2012 at 4:57am

Is this EventCalendar 3 or 2.4?

Avatar
seah0rse

Community Member, 5 Posts

6 December 2012 at 2:14pm

oops sorry this is 3.x. I see you have added a upcoming announcements method... Also my template example above does not have the dates var in it but I have been using $Debug to test. I understand that with the announcements VS the events that the events have dedicated pages whilst the announcements are on the same page as the calendar.. Just need to inject the url segment for the cal to the announcement link (absoluteLink())?

For the all calendars list and upcoming events and announcements - I was thinking if I could do a get on the calendar object and then for each call get_one and call the upcomingEvents method and then add the resulting array as children?

Thanks for your help.

Avatar
seah0rse

Community Member, 5 Posts

7 December 2012 at 10:39am

I can do this but not sure if it the right thing to do..? Also how do I template it?

public function AllCalendars() {
$set = new ArrayList;
$calendars = Calendar::get()->sort('Title');
$set->push($calendars);

foreach ($calendars as $calendar) {
$set->push($calendar->upcomingEvents(10));
}

//print_r($set);
return $set;
}

Avatar
UncleCheese

Forum Moderator, 4096 Posts

7 December 2012 at 10:41am

On the "Feeds" tab of your calendar, you can select other calendars to pipe into your main calendar. Just check off the ones you want, and then when you run UpcomingEvents() on your main calendar, it will include the events of all the other calendars that you selected.

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
UncleCheese

Forum Moderator, 4096 Posts

7 December 2012 at 10:41am

FYI, <% control %> is deprecated. Use <% loop %>.

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
seah0rse

Community Member, 5 Posts

7 December 2012 at 1:08pm

Edited: 07/12/2012 1:57pm

Thanks for the reply.. Ok so I can create a 'master' cal and then use the rss option to 'integrate' all my 'real' cal events and announcements into that cal. I do not want to display that cal on the site. Do I select the master cal dataobject in the home page controller like so?

So I need something like...

public function AllCalendars() {
return Calendar::get_by_id('Calendar', 11)->upcomingEvents(20);
}

and in my template

<% if AllCalendars %>
<h4>All Calendars</h4>
<ul>
<% loop AllCalendars %>
<% if Announcement %>
<li>$DateRange - $Title<br/>$Content.BigSummary(20)</li>
<% else %>
<li>$DateRange - <a href="{$Link}" title="More Details about {$Title}">$Title</a><br/>$Content.BigSummary(20)</li>
<% end_if %>
<% end_loop %>
</ul>
<% end_if %>

This works but I still have broken links in my announcements - they are formatted like: http://sitename/?date=2013-01-03
But I can fix this with some conditional code in my template to remove the link - (not great).

It would be nicer but trickier to have a summary of each cals up coming events and cals like I posted before..

Seniors events (cal name)
s event 1
s announce 1
s event 2
s announce 2
Masters events (cal name)
m event 1
m announce 1
m event 2
m announce 2
Juniors events (cal name)
j event 1
j announce 1
j event 2
j announce 2
etc...

Go to Top