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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

dataobjectdecorator in _config.php

Go to End

2 Posts   2087 Views


Community Member, 22 Posts

10 December 2008 at 7:22am

I added a dataobjectdecorator to the member object basically copying the ForumRole decorator example in the forum. My decorator is called ClubRole. So to use this decorator I need to include this line in the _config.php:

DataObject::add_extension('Member', 'ClubRole');

As I am using the Forum infrastructure there is the ForumRole decorator in the _config.php too:

DataObject::add_extension('Member', 'ForumRole');

So in the _config.php I have these two lines in this order:

DataObject::add_extension('Member', 'ClubRole');
DataObject::add_extension('Member', 'ForumRole');

So the problem I experienced is that $Link in the template returns the Link method defined in the ForumRole decorator instead of the one defined in the ClubRole decorator which is the intended one. How do I fix it? Commenting out the ForumRole decorator does the job but I feel that this is not the only way to do it.

Can't you have more than one decorator per object that you would like to decorate.

EG. I would like another member decorator called EmployeeRole.


Community Member, 25 Posts

10 December 2008 at 8:08am

You can probably do it by changing the order you add the extensions. If you have the Club first, it will be overwritten by the Forum (I'm guessing). Try them front to back, and see if it's any good :)