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.

Customising the CMS /

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

How to use BBCodeParser in PHP code?


Go to End


3 Posts   1676 Views

Avatar
cardinale

Community Member, 23 Posts

21 March 2010 at 10:19am

How to use BBCodeParser in PHP code?

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

Avatar
cardinale

Community Member, 23 Posts

21 March 2010 at 10:35am

I found the solution :-)

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

Avatar
hornergraphic

Community Member, 4 Posts

7 December 2010 at 2:41am

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.