10447 Posts in 2223 Topics by 1719 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 943 Views |
-
Event Calendar - Past Events

13 April 2010 at 7:47am Last edited: 13 April 2010 7:51am
Hi, Does anyone know how to show past events from the Event Calendar?
I know there's the upcomingEvent function but is there a past/previous event function? I want to show a list of past event teasers on the homepage, yesterday and back - my current code
function Events() {
$today = date("Y-m-d");
return DataObject::get_one("Calendar")->Events(null, $today, null, false, 5, null);
}
just shows all upcoming events and trying something like<% control PreviousEvents %>
$Event.Title $_Dates $Event.Link, etc..
<% end_control %>gives no joy either,
..any ideas?
-
Re: Event Calendar - Past Events

13 April 2010 at 8:32am
I believe the function RecentEvents() is decorated into your SiteTree.
-
Re: Event Calendar - Past Events

13 April 2010 at 9:08am
No joy with
function RecentEvents() {
$today = date("Y-m-d");
return DataObject::get_one("Calendar")->RecentEvents(null, $today, null, false, 5, null);
}
and this in the .ss file<% if RecentEvents %>
<% control RecentEvents %>
<dl class="diary-events">
<dt>$_Dates</dt>
<dd><h4 class="summary"><% if Announcement %><a href="$Link">$RecentEventsTitle</a><% else %><a href="$Link">$RecentEventsTitle</a><% end_if %></h4>
<% if Announcement %>
$Content
<% else %>
<% control RecentEvents %>$Content.LimitWordCount(60)<% end_control %> <a href="$Link"><% _t('MORE','more...') %></a>
<% end_if %>
<br />
<% if Announcement %><a href="$Link">Read More…</a><% else %><a href="$Link">Read More…</a><% end_if %>
</dd>
</dl>
<% end_control %>Sent you an email over the weekend so best wait till I hear back from you re: this with the other stuff.
-
Re: Event Calendar - Past Events

13 April 2010 at 9:16am
Oh, this is Adam? Hey, there.. Will get back to you tonight.
You shouldn't have to write a function. The RecentEvents() function is decorated on your SiteTree class, just like UpcomingEvents. The first argument is the number of events to show (default is 5), and the second is a url-segment to the calendar you want to draw from. If null, it gets the first Calendar it finds in the DB. For sites with one calendar, you can usually just leave those both empty.
So delete any functions you've written, and just let the core function do its thing. You should be able to call <% control RecentEvents %> on any SiteTree subclass.
-
Re: Event Calendar - Past Events

13 April 2010 at 9:43am
:o) Yep tis me, UC, had a footle with that but my mojo is obviously not working tonight, no worries, catch up with you later ;o) ta!
| 943 Views | ||
|
Page:
1
|
Go to Top |

