Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » How do I override a function in a decorator?

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

Page: 1
Go to End
Author Topic: 1419 Views
  • micahsheets
    Avatar
    Community Member
    164 Posts

    How do I override a function in a decorator? Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: How do I override a function in a decorator? Link to this post

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

  • micahsheets
    Avatar
    Community Member
    164 Posts

    Re: How do I override a function in a decorator? Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: How do I override a function in a decorator? Link to this post

    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.

    1419 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.