Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Calendar event module - upcoming events on homepage?

Discuss all other Modules here.

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

Page: 1 2 3 4 5
Go to End
Author Topic: 5882 Views
  • FireMe!
    Avatar
    Community Member
    74 Posts

    Calendar event module - upcoming events on homepage? Link to this post

    Hi

    Its fireme asking for help again lol, Ok i have the calendar event module and would like to have next 5 upcoming event on the home page. the same as i got the top 5 latest news articles. But as im not a php guru, i dont know how to do it. So as you are all very nice and helpful i thought i would ask here.

    Thanks in advance

    FireMe!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Calendar event module - upcoming events on homepage? Link to this post

    $myCalendar->upcomingEvents(5);

  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: Calendar event module - upcoming events on homepage? Link to this post

    where would i put this?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Calendar event module - upcoming events on homepage? Link to this post

    In your homepage controller.

    function UpcomingEvents()
    {
    return DataObject::get_one("Calendar")->upcomingEvents(5);
    }

    <% control UpcomingEvents %>
    <h3>$_Dates</h3>
    <h4><a href=$Event.Link">$Event.Title</a></h4>
    <% end_control %>

  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: Calendar event module - upcoming events on homepage? Link to this post

    Thanks that worked great, is there also a way if the latest event is in the past to still display as upcoming?, see i dont want a blank part of the home page if there is no upcoming events. if you get what i mean??

    Thanks in advance

  • UncleCheese
    Avatar
    4085 Posts

    Re: Calendar event module - upcoming events on homepage? Link to this post

    There should be a recentEvents() function, as well. Try it. If not, I'll add it in.

    Also, FYI, the second argument of those functions is a filter in case you want to do something like upcomingEvents(5, "Category = 'Blah')

  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: Calendar event module - upcoming events on homepage? Link to this post

    i tried the following but didn't seem to work.

    function RecentEvents()
    {
    return DataObject::get_one("Calendar")->RecentEvents(5);
    }

    also i am trying to format the date, the same as i did for my latest news

    <div class="month">$Date.Format(M)</div>

    <div class="day">$Date.Format(d)</div>

    i have tried

    <div class="month">$_Dates.Format(M)</div>

    <div class="day">$_Dates.Format(d)</div>

    but does not work and i get

    Fatal error: Call to a member function XML_val() on a non-object

  • UncleCheese
    Avatar
    4085 Posts

    Re: Calendar event module - upcoming events on homepage? Link to this post

    $StartDate and $EndDate are the properties you're looking for. $_Dates is a magic method that returns a human readable date range (e.g. October 10-20, 2009) in microformat compliant markup.

    5882 Views
Page: 1 2 3 4 5
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.