10390 Posts in 2201 Topics by 1712 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 856 Views |
-
EventCalendar - Modifying Announcements

25 January 2010 at 2:52am
Hello,
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 functionthat 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.extendAnnouncement
What is the best way to do it? -
Re: EventCalendar - Modifying Announcements

25 January 2010 at 4:10am
extendAnnouncement() is what you want. In your DateTime subclass:
public function extendAnnouncement() {
$this->addAnnouncementFields(array(
new TextField('SomeCustomField'),
new DropdownField('SomeRelationID','Choose related thing')
));$this->addAnnouncementTitles(array(
'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.
| 856 Views | ||
|
Page:
1
|
Go to Top |

