Jump to:

23376 Posts in 18218 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Placeholder within the editor?

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: 1693 Views
  • bschmitt
    Avatar
    Community Member
    22 Posts

    Placeholder within the editor? Link to this post

    Hi

    For modifying content before saving to database I can use the following code within a page:

    function onBeforeWrite() {
    $this->Content = str_replace("[[placeholder]]", "replacement123", $this->Content);
    parent::onBeforeWrite();
    }

    Is there a method to call to reset to the placeholder string before the content gets loaded to the editor?

    Something like this?

    function onBeforeLoadToEditor() {
    $this->Content = str_replace("replacement123", "[[placeholder]]", $this->Content);
    parent::onBeforeLoadToEditor();
    }

    Thanks, Bjoern

  • bschmitt
    Avatar
    Community Member
    22 Posts

    Re: Placeholder within the editor? Link to this post

    According to this tutorial http://doc.silverstripe.com/doku.php?id=recipes:customising-content-in-your-templates&s=paypal I found a better solution for this:

    class Page_Controller extends ContentController {

    function Content() {
    return str_replace("[[placeholder]]", "replacement123", $this->Content);
    }
    }

    This replaces the placeholder for the view but stores the original content in the database.

    Best, Bjoern

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