10441 Posts in 2220 Topics by 1717 members
| Go to End | Next > | |
| Author | Topic: | 1565 Views |
-
event_calendar: Upcoming Events on Startpage

7 May 2010 at 3:06am
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 andfunction 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
-
Re: event_calendar: Upcoming Events on Startpage

7 May 2010 at 4:24am
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 %>
-
Re: event_calendar: Upcoming Events on Startpage

7 May 2010 at 5:41am
Okay, dummy fault...
So now I get no events (but there are). -
Re: event_calendar: Upcoming Events on Startpage

7 May 2010 at 7:34am
function UpcomingEvents()
{
return DataObject::get_one("Calendar")->UpcomingEvents(5);
}and
<div id="events">
<% control UpcomingEvents %>
$UpcomingEvents
<% end_control %>
</div>Output is just the <div>
-
Re: event_calendar: Upcoming Events on Startpage

7 May 2010 at 8:11am
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> -
Re: event_calendar: Upcoming Events on Startpage

8 May 2010 at 11:26am
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.
-
Re: event_calendar: Upcoming Events on Startpage

8 May 2010 at 12:09pm
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!
| 1565 Views | ||
| Go to Top | Next > |
