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

How to pull upcoming events but from one of two calendar


Reply

3 Posts   898 Views

Avatar
otherjohn

4 June 2010 at 9:49am Community Member, 125 Posts

Hi all,
I have the event-calendar setup for regular calendar use. Then I created a module that is an extension of the event calendar that is for certain group meetings. This one is extended with event address, map, etc.

On the homepage of the site, I would like to pull upcoming events, but only from the regular calendar. Not from the extended one.

When I use the following code in my page.php file, it pulls back events from the extended calendar.

public function UpcomingNonAnnouncements()
{
return DataObject::get_one("Calendar")->upcomingEvents(5);
}

Any idea how I can fix this?

Avatar
UncleCheese

4 June 2010 at 12:48pm 4085 Posts

get_one("Calendar") is just going to select one arbitrarily. You need to add more criteria if you want to get a specific one.

Keep in mind, the UpcomingEvents() function that is decorated into all SiteTree objects takes a URLSegment as a second argument..

<% control UpcomingEvents(5,some-calendar) %>

Avatar
DanStephenson

19 October 2011 at 3:59pm (Last edited: 19 October 2011 5:35pm), Community Member, 115 Posts

Hi Uncle Cheese,

Is there a way I can test for if there are any upcoming events in a calendar? Essentially I have a sidebar block on my homepage showing my latest events, incluidng a headline of Latest Events. If there are no events I want the whole block to not be displayed.