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 Module - How to Question


Go to End


11 Posts   3481 Views

Avatar
Bstarr

Community Member, 25 Posts

28 June 2011 at 9:41am

Is there a way to show the next two events on another page besides the main events page? I have a space on my home page for upcoming events and if possible I'd like this to show the next two events as opposed to me having to update that page manually myself. Is there a way to do this?

I'm not a developer, so writing scripts isn't an option for me. I'm just wondering if there is a fairly simple way to achieve this. Any help you can provide is greatly appreciated.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

28 June 2011 at 4:49pm

<% control UpcomingEvents %>

Avatar
IDOLYZ

Community Member, 40 Posts

28 June 2011 at 4:55pm

Hi UncleCheese,

I have a similar problem. I can get the next upcoming event to show, however when I added 2 more calendars to my site, it isn't showing the next upcoming event anymore. This is my function code:

return DataObject::get_one("Calendar")->upcomingEvents(1);

How can I specify a parent ID to the above?

I tried this:

$event = DataObject::get_one("Calendar");
return ($event) ? DataObject::get("CalendarEvent", "ParentID=16", "", "", 1) : false;

But it shows past events.

Any help would be greatly appreciated.

Cheers,
Ben

Avatar
Bstarr

Community Member, 25 Posts

29 June 2011 at 8:23am

I think I'm still missing what to do with that line of code. I added it in but it isn't working and the WYSIWYG Editor actually strips out the "<" and ">". What am I doing wrong?

<td width="290px">
<h2>News &amp; Events</h2>
<table id="News &amp; Events Table" style="width: 100%;" border="0">
<tbody>
<tr valign="top">
<td><% control UpcomingEvents %></td>
</tr>
<tr valign="top">
<td>
<p><a class="link" href="[sitetree_link id=16]">view other events</a></p>
</td>
</tr>
</tbody>
</table>
</td>

Avatar
IDOLYZ

Community Member, 40 Posts

29 June 2011 at 12:21pm

You need to add it to your Page.SS file (or whichever page type it is).

Avatar
Bstarr

Community Member, 25 Posts

29 June 2011 at 12:37pm

Thanks, so there is no way to have it just on that one page? I don't want it everywhere there is a cell in a table that is supposed to show the next two events that appears only on the home page.

Avatar
IDOLYZ

Community Member, 40 Posts

29 June 2011 at 12:43pm

Yes, you could either create a new template for the home page. See: http://doc.silverstripe.org/sapphire/en/tutorials/1-building-a-basic-site

Or you could put an if statement, like this:

<% if Page(home) %>
<table id="News &amp; Events Table" style="width: 100%;" border="0">
<tbody>
<% control UpcomingEvents %>
<tr>
<td>$Event.CalendarEventImage
<h3><a href="$Event.Link">$Event.Title</a></h3>
<h4>$_Dates</h4>
$Event.Content</td>
</tr>
<% end_control %>
</tbody>
</table>
<% end_if %>

The above is untested...

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 June 2011 at 3:25pm

Its much better to make a custom page type. If you're putting structural markup in the wysiwyg editor, you've really missed the whole point of silverstripe, and you need to read the tutorial above.

Go to Top