Jump to:

11003 Posts in 2735 Topics by 1824 members

All other Modules

SilverStripe Forums » All other Modules » EventCalendar - Modifying Announcements

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1007 Views
  • silk
    Community Member
    18 Posts

    EventCalendar - Modifying Announcements Link to this post


    I am expanding the EventCalendar a little bit and everything is working fine
    as long I adapt the CalendarEvents (like adding a field to the database and adding appropriate elements in the CMS). For 90% of my events the announcement structure would be a better solution, though (small content and having all the good things from DataObjectManager). Now I want to tweak the announcements, too (again: like adding a field to the database and adding appropriate elements in the CMS with updateCMSFields).

    Adding fields is no problem, using the SiteTreeDecorator-approach I added the fields to CalendarDateTime. Now I should be able to use them for CalendarEvents and Announcements. Neat! Now that I think about it, CalendarDateTime is a DataObject and no SiteTree Descendant, so this is not the correct way to do it, is it?

    Now my main question:
    Is there any way to change the CMS with something like updateCMSFields for the announcements as well?
    I see there is a abstract function


    that seems to do something like this. So I have to derive from it? I'd love to have a way to do it with decorators, though.
    What is the best way to do it?

  • UncleCheese
    4085 Posts

    Re: EventCalendar - Modifying Announcements Link to this post

    extendAnnouncement() is what you want. In your DateTime subclass:

    public function extendAnnouncement() {
    new TextField('SomeCustomField'),
    new DropdownField('SomeRelationID','Choose related thing')

    'SomeCustomField' => 'Some custom title'

    I thought for a long time about using decorators, but there were two main reasons why I opted not to do so:

    1) Decorators are enigmatic and inaccessible to most Silverstripe programmers. There's little documentation on them, and it's just not as mainstream a practice as subclassing.

    2) I didn't like the idea of making global alterations to the calendar/event/datetime models. I thought it was a viable scenario that one would have multiple calendars, each with different data models.

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.