Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Batch OnBeforeWrite

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

Page: 1
Go to End
Author Topic: 1448 Views
  • rs82uk
    Community Member
    3 Posts

    Batch OnBeforeWrite Link to this post

    Hi there, I am using OnBeforeWrite to populate my meta data and this is working great, however can anyone tell me if there is a way that I can tie this into the batch publish in Silverstripe?
    Thanks in advance


  • banal
    Community Member
    901 Posts

    Re: Batch OnBeforeWrite Link to this post

    Hi Rohan

    I never did this, but I guess you could subclass SiteTreeDecorator, override the onBeforePublish method in your new class and use it as decorator for SiteTree. The decorator can be applied using the $extensions array or by calling DataObject::add_extension() in your _config.php.

    The onBeforePublish method of the decorator will be called every time the page is being published, that probably includes batch publishing as well.

  • Garrett
    Community Member
    245 Posts

    Re: Batch OnBeforeWrite Link to this post


    I also need to use onBeforePublish() on a BlogEntry to populate a hidden field I need. I've added the method to BlogEntry.php thinking this would overload it from SiteTreeDecorator but I not so:

    500 Error: "Uncaught Exception: Object->__call(): the method 'onbeforepublish' does not exist on 'BlogEntry'"

    What do I have to do to overload this method and capture the onBeforePublish event in when BlogEntry is published? Seems odd I would have to create a new file for this.

    Thanks in advance,

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.