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.

All other Modules

Discuss all other Modules here.

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

Event Calendar - Upcoming Events Control


Go to End
Reply

17 Posts   2901 Views

Avatar
churika

8 June 2010 at 1:48am (Last edited: 8 June 2010 1:49am), Community Member, 29 Posts

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

8 June 2010 at 1:54am 4085 Posts

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

8 June 2010 at 2:03am Community Member, 29 Posts

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

8 June 2010 at 2:27am Community Member, 29 Posts

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

Avatar
UncleCheese

8 June 2010 at 3:21am 4085 Posts

What does "getting some errors" mean?

Avatar
churika

8 June 2010 at 8:17am (Last edited: 8 June 2010 8:23am), Community Member, 29 Posts

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

8 June 2010 at 8:24am (Last edited: 8 June 2010 8:25am), 4085 Posts

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

8 June 2010 at 11:40am (Last edited: 8 June 2010 11:41am), Community Member, 29 Posts

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

Go to Top