Jump to:

23355 Posts in 17734 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » How to change Content before saving?

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: 1328 Views
  • dab
    Avatar
    Community Member
    50 Posts

    How to change Content before saving? Link to this post

    Im want to make post editor for Page Content (for good typography, like set up right dashes and quotes), i may call it every time i render page, but better and quicker solution is change Content before saving. So how i may do it?
    Thank you.

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: How to change Content before saving? Link to this post

    You can define a onBeforeWrite function on your page type. Eg if you want to edit the page content before you write to the database you would need to add this to your mysite/code/Page.php in the Page class

    function onBeforeWrite() {
    // do something
    parent::onBeforeWrite();
    }

    For more information see http://doc.silverstripe.com/doku.php?id=datamodel#onbeforewrite

    1328 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.