Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Content Filters

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1778 Views
  • Nathan Cox
    Community Member
    99 Posts

    Content Filters Link to this post


    Tell me if something like this exists, but I'm thinking it would be useful to have some kind of content filter system...something that lets you apply filters/make changes to content before it gets displayed on the page.

    I was thinking two potential uses:

    1) automatically adding <acronym> or <abbr> tags, or styling external links differently. For example, have a filter object that finds the first occurrence of "CSS" in the page content and replaces it with "<acronym title='Cascading Style Sheets'>CSS</acronym>".

    2) putting page properties in the content. If you want a contact page that has a few paragraphs of content, then displays a contact form, then has some more content it would be great to be able to put something like {$Form} in the content and have it replaced with the page's form on the frontend.


  • Sam
    679 Posts

    Re: Content Filters Link to this post

    Good idea, but this would be quite site-specific.

    The simplest thing way to implement this on a site would be to create a Content() method that returned some processed version of $this->Content.

    This works because
    * The editing form will only look at $this->Content
    * The template will prefer to use $this->Content() over this->Content

    So, add something like this in your Page class...

    function Content() {
    return str_replace('GPL', '<abbr title="GNU Public License">GPL</abbr>', $this->Content);

  • Nathan Cox
    Community Member
    99 Posts

    Re: Content Filters Link to this post

    You know, I didn't think of that...I guess in most cases there might not be enough benefit to having a dedicated system for it.

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.