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

way to access specific events calendar?


Reply


4 Posts   519 Views

Avatar
prawnstar

Community Member, 116 Posts

10 August 2010 at 6:48am

Edited: 10/08/2010 6:49am

I have multiple event calendars on my site. One calendar for the main organization and multiple calendars for member organizations.

All of that works great if I only access the events from the calendar page for each respective member organization, but I'd like to display a "teaser" on other pages of the site. E.g on a member home page, I'd like to display the current event for that member.

My problem is, accessing only that member's data. Currently I'm doing something like this:

// current member organization event
   function memberEvent($num=2) {
      return DataObject::get("CalendarEvent", "ParentID = 27", "ID DESC", "", $num);
   }

The problem is that I can't know the ID of the next member *until* that member created a calendar. this obviously requires a programmer to fix, but I'm trying to make it possible that they can create a calendar without having to call the programmer.

I'm not opposed to doing it this way(it is reasonable), but is there another way of doing this that I'm just simply not thinking about?

Any suggestions are greatly appreciated.

Thanks!
Chris.b

Avatar
UncleCheese

4085 Posts

10 August 2010 at 8:12am

Sounds like you need to decorate your Member object, and give them a $has_one Calendar. Then you could just do:

public function MemberEvents() {
return $this->Calendar()->UpcomingEvents();
}

Avatar
prawnstar

Community Member, 116 Posts

10 August 2010 at 9:32am

Edited: 10/08/2010 9:32am

Thanks UncleCheese!

Forgive me, as I am very new to OOP-php, so while I get the gist I don't 100% understand. It sounds like

return $this->Calendar()->UpcomingEvents();

will return the Calendar for $this Member. $this Member being the owner of that page determined by the controller having a has_one relationship with the Calendar class.

For reasons (other than/as well as) this method is slightly above my head, I opted to go for hard coded ID's because the events may appear on pages that the Member doesn't own. I'm assuming that this method wouldn't apply in that situation?

Please forgive me if this next comment is inappropriate for this forum, but where would I look to hire an independent programmer to assist with some of the more high-level questions I have regarding this type of functionality? I looked at the SS partners page, but the vast majority of them seem to be companies, rather than independent contractors.

Thanks!
Chris.b

Avatar
UncleCheese

4085 Posts

10 August 2010 at 9:45am

Yeah, I stay pretty busy doing commissioned support and improvements for all my modules and other projects. Feel free to ping me through my website.. carlinowebdesign.com