Jump to:

10928 Posts in 2612 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » way to access specific events calendar?

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 493 Views
  • prawnstar
    Avatar
    Community Member
    116 Posts

    way to access specific events calendar? Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: way to access specific events calendar? Link to this post

    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();
    }

  • prawnstar
    Avatar
    Community Member
    116 Posts

    Re: way to access specific events calendar? Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: way to access specific events calendar? Link to this post

    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

    493 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.