Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » How to use BBCodeParser in PHP code?

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

Page: 1
Go to End
Author Topic: 1004 Views
  • cardinale
    Avatar
    Community Member
    23 Posts

    How to use BBCodeParser in PHP code? Link to this post

    How to use BBCodeParser in PHP code?

    This is not working!
    new LiteralField ('Text', BBCodeParser::setContent($this->Text).'<br><br><br>')

  • cardinale
    Avatar
    Community Member
    23 Posts

    Re: How to use BBCodeParser in PHP code? Link to this post

    I found the solution

    TextParser::create('BBCodeParser', $this->Text )->parse()

  • hornergraphic
    Avatar
    Community Member
    4 Posts

    Re: How to use BBCodeParser in PHP code? Link to this post

    Thanks for the post cardinale! Saved me a lot of time. If you want to implement this globally on your site this might be a handy function to add to your Page.php base class:

    class Page extends SiteTree {

       ....

       public function getParsedContent() {
          return TextParser::create('BBCodeParser', $this->Content )->parse();
       }

       ...
    }

    Then just include $ParsedContent on your page templates to get it out the frontend.

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