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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

How do I override a function in a decorator?


Reply

4 Posts   1454 Views

Avatar
micahsheets

5 January 2011 at 11:08am Community Member, 164 Posts

The function Children() is now in the decorator called "Hierarchy". I want to modify the way the Children() function works for RedirectorPage types. In the olden days I would just create my own Children() function in Page.php and be done. However now that doesn't work in 2.4.4 because I don't know how to override the Children() function in the decorator.

Avatar
Willr

6 January 2011 at 9:00pm Forum Moderator, 5511 Posts

Perhaps just call your function MyChildren() and then use that in your template? Decorators are applied after everything else.

Avatar
micahsheets

7 January 2011 at 8:54am Community Member, 164 Posts

This question is bigger than this particular problem. More and more I am running into needing to modify behavior that I used to be able to just do in my Page Class but now those functions have been moved to decorators. So I really want to know how to subclass a decorator or even decorate a decorator.

Avatar
Willr

7 January 2011 at 7:00pm Forum Moderator, 5511 Posts

So I really want to know how to subclass a decorator or even decorate a decorator.

You get into some pretty horrible territory with debugging extensions all over the place. I haven't needed to extend versioned etc that much before so don't know the correct way but you could try removing the extension from a class and applying your own which could subclass the existing extension.