3067 Posts in 867 Topics by 649 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1079 Views |
-
Decorater Problem

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
-
Re: Decorater Problem

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"
-
Re: Decorater Problem

23 March 2009 at 10:15pm Last edited: 23 March 2009 10:56pm
You're right, that space isn't in the original code...
for further informations, my classes are structed like this:
Page.phpclass Page extends SiteTree { ... }
SubPage.php
class SubPage extends Page { ... }
myPageDecorater.php
class myPageDecorater extends DataObjectDecorator{
public function TestFunction(){
return "TestFunction of myPageDecorater ";
}
}mySubPageDecorater.php
class mySubPageDecorater extends DataObjectDecorator{
public function AnotherTestFunction(){
return "TestFunction of mySubPageDecorater ";
}
}_config.php
...
DataObject::add_extension('Page', 'myPageDecorater');
DataObject::add_extension('SubPage', 'mySubPageDecorater');
...TestFunction is accessible on both classes, but i can't call AnotherTestFunction.
-
Re: Decorater Problem

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...
| 1079 Views | ||
|
Page:
1
|
Go to Top |



