Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Embarassingly simple question re. Event Calendar

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 965 Views
  • Ian Dav
    Avatar
    Community Member
    2 Posts

    Embarassingly simple question re. Event Calendar Link to this post

    Hi there,

    I'm sure this is something incredibly easy to do, but for some reason I can't get my head round it...

    All I want to do is list back the latest 3 events from the Event Calendar module on the site homepage. Doesn't need anything fancy - just:

    [Date] [Event/Announcement title] [Link to event] .... much as you would to bring back "latest news" headlines from a news section.

    I'm the first to hold my hands up and say I'm not the greatest PHP-er in the world, but I think I'm probably over-complicating things here in looking for a solution. Either that or my brain is fried from deadlines and I can't see the wood for the trees...

    Is there a function I can define in my HomePage.php that will enable me to do such a thing?

    Hoping someone can help

  • UncleCheese
    Avatar
    4085 Posts

    Re: Embarassingly simple question re. Event Calendar Link to this post

    Absolutely. On any page, you can use <% control UpcomingEvents(number) %>

    If no number is provided, it defaults to 5 events. If you have multiple calendars, you can supply the URLSegment of the calendar you want to draw from as the second argument.

    <% control UpcomingEvents(3) %>
    <li>$_Dates $EventTitle $Link</li>
    <% end_control %>

  • UncleCheese
    Avatar
    4085 Posts

    Re: Embarassingly simple question re. Event Calendar Link to this post

    Absolutely. On any page, you can use <% control UpcomingEvents(number) %>

    If no number is provided, it defaults to 5 events. If you have multiple calendars, you can supply the URLSegment of the calendar you want to draw from as the second argument.

    <% control UpcomingEvents(3) %>
    <li>$_Dates $EventTitle $Link</li>
    <% end_control %>

  • Ian Dav
    Avatar
    Community Member
    2 Posts

    Re: Embarassingly simple question re. Event Calendar Link to this post

    Fantastic stuff! I knew it would be something simple

    Tried, tested and successful. Thanks for your help Uncle C

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: Embarassingly simple question re. Event Calendar Link to this post

    Is there any way of passing date filters to UpcomingEvents (or other built in functions) for pages away from the actual calendar template?

    ie, I have a page template which lists a print ready version of Calendar Events in a specific format. What I really need to be able to do is start the page off (on first view) with all the currents months events, then let the user select which month they can print , either with calendarwidget or something like the MonthNavigator..

    any ideas??

  • UncleCheese
    Avatar
    4085 Posts

    Re: Embarassingly simple question re. Event Calendar Link to this post

    Hey, Nick,

    All of the key functions in the Calendar class are publicly accessible. You just have to make sure you get an instance first. Some of the most common functions are decorated into the SiteTree (e.g. UpcomingEvents()), which just automatically get a Calendar instance for you, based on URL segment, or most commonly, the only one you have in your SiteTree.

    So you can write a custom function of your liking, and as long as you get something like:

    $calendar = DataObject::get_one("Calendar" .... );

    You can return:

    $calendar->Events($filter = null, $start_date = null, $end_date = null, $default_view = false, $limit = null, $announcement_filter = null)

    965 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.