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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

Placeholder within the editor?


Go to End


2 Posts   2514 Views

Avatar
bschmitt

Community Member, 22 Posts

11 March 2009 at 2:24am

Edited: 11/03/2009 2:26am

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

Avatar
bschmitt

Community Member, 22 Posts

12 March 2009 at 12:01am

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