Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Event Calendar - Upcoming Events Control


Go to End


17 Posts   5668 Views

Avatar
churika

Community Member, 29 Posts

8 June 2010 at 1:48am

Edited: 08/06/2010 1:49am

I've been trying to pull the next 4 upcoming events from a calendar on to a home page for a few weeks now to no avail using the predefined global UpcomingEvents control. I'm not understanding where and how to use this function or control and the times I've tried have pulled up no results. Anyone have any further information on how to use this function?

Also, would I have access to the $_Dates function pulling them in through the control?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 June 2010 at 1:54am

On any page, you can use the UpcomingEvents() function that is decorated on your SiteTree to pull in the upcoming events from your calendar, e.g.

<ul>
<% control UpcomingEvents(4) %>
<li>$_Dates $EventTitle</li>
<% end_control %>
</ul>

If you have multiple galleries, you'll have to pass the URLSegment of the gallery you want to use as the second argument.

Avatar
churika

Community Member, 29 Posts

8 June 2010 at 2:03am

Ah ok, I have multiple galleries which probably explains why I wasn't getting any results.

Passed like <% control UpcomingEvents(4, 'events') %>

if the URL Segment of that calendar is /events

Avatar
churika

Community Member, 29 Posts

8 June 2010 at 2:27am

Getting some page errors with <% control UpcomingEvents(4, 'events') %> and <% control UpcomingEvents(4, events) %>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 June 2010 at 3:21am

What does "getting some errors" mean?

Avatar
churika

Community Member, 29 Posts

8 June 2010 at 8:17am

Edited: 08/06/2010 8:23am

for

<% control UpcomingEvents(4, 'events') %>

it says "Parse error: syntax error, unexpected '}' in C:\Users\Nick\AppData\Local\Temp\silverstripe-cacheD--Web-xampp-htdocs\.cacheD..Web.xampp.htdocs.PJCBG.templates.HomePage.ss on line 232"

and for

<% control UpcomingEvents(4, events) %>

it says "Fatal error: Call to a member function XML_val() on a non-object in C:\Users\Nick\AppData\Local\Temp\silverstripe-cacheD--Web-xampp-htdocs\.cacheD..Web.xampp.htdocs.PJCBG.templates.HomePage.ss on line 199"

without any parameters or just 4 as a parameter it still says "Fatal error: Call to a member function XML_val() on a non-object in C:\Users\Nick\AppData\Local\Temp\silverstripe-cacheD--Web-xampp-htdocs\.cacheD..Web.xampp.htdocs.PJCBG.templates.HomePage.ss on line 199"

and i forgot to mention that without the control there are no errors in the page

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 June 2010 at 8:24am

Edited: 08/06/2010 8:25am

Well the first error is because you can't use quotes like that. The other error is unrelated to the control statement. You have an error within the control somewhere, but I can't tell you what it is without any context.

Use ?showtemplate=1 in your URL to find the line it's referring to.

Avatar
churika

Community Member, 29 Posts

8 June 2010 at 11:40am

Edited: 08/06/2010 11:41am

?showtemplate=1 didn't change anything =/ i'll see if i can find further context for you

Go to Top