Jump to:

10990 Posts in 2727 Topics by 1818 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar - Past Events

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1119 Views
  • bod
    Avatar
    Community Member
    72 Posts

    Event Calendar - Past Events Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar - Past Events Link to this post

    I believe the function RecentEvents() is decorated into your SiteTree.

  • bod
    Avatar
    Community Member
    72 Posts

    Re: Event Calendar - Past Events Link to this post

    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&#8230;</a><% else %><a href="$Link">Read More&#8230;</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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar - Past Events Link to this post

    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.

  • bod
    Avatar
    Community Member
    72 Posts

    Re: Event Calendar - Past Events Link to this post

    :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!

    1119 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.