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.

Data Model Questions /

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

Decorater Problem

Go to End

4 Posts   1609 Views


Community Member, 18 Posts

22 March 2009 at 4:40am

I have a page class and a subPage class which extends the page-class.
now i want to decorate the page class with a decorater myPageDecorater.
And the sub class with an other decorater mySubPageDecorater.

In _config.php the decoraters are added like that:

DataObject::add_extension('Page', 'myPageDecorater');
DataObject::add_extension('SubPage ', 'mySubPageDecorater');

The Problem is, the second Decorater is not added. No functions of the DecorationClass can be used...

Is there any other way to add a specific decoration on SubPage?

Thanks for you help, Michael


Forum Moderator, 922 Posts

23 March 2009 at 9:24pm

I'm assuming you didn't put that space after SubPage in your actual code?

e.g. "SubPage " instead of "SubPage"


Community Member, 18 Posts

23 March 2009 at 10:15pm

Edited: 23/03/2009 10:56pm

You're right, that space isn't in the original code...
for further informations, my classes are structed like this:

class Page extends SiteTree { ... }


class SubPage extends Page { ... }


class myPageDecorater extends DataObjectDecorator{ 
   public function TestFunction(){
      return "TestFunction of myPageDecorater ";


class mySubPageDecorater extends DataObjectDecorator{
   public function AnotherTestFunction(){
      return "TestFunction of mySubPageDecorater ";


DataObject::add_extension('Page', 'myPageDecorater');
DataObject::add_extension('SubPage', 'mySubPageDecorater');

TestFunction is accessible on both classes, but i can't call AnotherTestFunction.


Community Member, 21 Posts

1 May 2009 at 9:13am

I'm having a similar problem, so I figured I'd give this thread a bump...

I want to decorate the CalendarEvent class from the Event module, which extends the Page class directly. I've created the extension class:

class MemberEventRole extends DataObjectDecorator {

and added the extension in the _config.php file of my module:

DataObject::add_extension("CalendarEvent", "MemberEventRole");

The decoration isn't working. Is there something about the order in which DataObjects load that could be causing a problem here? I'm also extending the core Member class in the same _config.php file, and it's working fine...