Jump to:

10850 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » event_calendar: Upcoming Events on Startpage

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 1769 Views
  • oleze
    Avatar
    Community Member
    64 Posts

    event_calendar: Upcoming Events on Startpage Link to this post

    Hey guys,
    i have a problem with the UpcomingEvents function of the event_calendar module in SilverStripe 2.4. I'd like to display the next 5 events on the startpage in a sidebarbox. I tried using $UpcomingEvents directly and

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

    which I found in another thread. Both don't work. I get some HTML with empty links:

    <div id="events">
    <ul id="Menu1">
    <li onclick="location.href = this.getElementsByTagName('a')[0].href"><a href=""></a></li>
    <li onclick="location.href = this.getElementsByTagName('a')[0].href"><a href=""></a></li>
    <li onclick="location.href = this.getElementsByTagName('a')[0].href"><a href=""></a></li>
    <li onclick="location.href = this.getElementsByTagName('a')[0].href"><a href=""></a></li>
    </ul>
    </div>

    and yes, I only get four of those.
    Thanks for your help.

    oleze

  • UncleCheese
    Avatar
    4085 Posts

    Re: event_calendar: Upcoming Events on Startpage Link to this post

    It returns a dataobjectset. You can't just put $UpcomingEvents on your template. You have to loop through each event in a control.

    <% control UpcomingEvents %>

  • oleze
    Avatar
    Community Member
    64 Posts

    Re: event_calendar: Upcoming Events on Startpage Link to this post

    Okay, dummy fault...
    So now I get no events (but there are).

  • UncleCheese
    Avatar
    4085 Posts

    Re: event_calendar: Upcoming Events on Startpage Link to this post

    Post your code?

  • oleze
    Avatar
    Community Member
    64 Posts

    Re: event_calendar: Upcoming Events on Startpage Link to this post

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

    and

    <div id="events">
             <% control UpcomingEvents %>
                $UpcomingEvents
             <% end_control %>
          </div>

    Output is just the <div>

  • UncleCheese
    Avatar
    4085 Posts

    Re: event_calendar: Upcoming Events on Startpage Link to this post

    You need to loop through the events.. It works just like any other control block.

    <ul>
    <% control UpcomingEvents %>
    <li>$_Dates : $Event.Title</li>
    <% end_control %>
    </ul>

  • oleze
    Avatar
    Community Member
    64 Posts

    Re: event_calendar: Upcoming Events on Startpage Link to this post

    Okay, that makes sense when using control. I'm using Image Gallery's RecentImages function and that works without control but the control-element makes styling much more flexible.

    Thank you for your help.

  • UncleCheese
    Avatar
    4085 Posts

    Re: event_calendar: Upcoming Events on Startpage Link to this post

    I struggled with the $RecentImageGallery function. That's a pretty bad breech of the MVC pattern do bundle that much markup into a single template variable, but ultimately I decided it was worth it due to all the Javascript and CSS dependencies with the popup plugins.

    Glad you got it working, though!

    1769 Views
Page: 1 2
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.