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:

General Questions /

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

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

How do I override a function in a decorator?


Go to End


4 Posts   1860 Views

Avatar
micahsheets

Community Member, 165 Posts

5 January 2011 at 11:08am

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

Forum Moderator, 5523 Posts

6 January 2011 at 9:00pm

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

Avatar
micahsheets

Community Member, 165 Posts

7 January 2011 at 8:54am

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

Forum Moderator, 5523 Posts

7 January 2011 at 7:00pm

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.