• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Accept BB code in a generic text input and render as HTML

Chris D

XenForo developer
Staff member
#1
I want to put a generic text input box in a template which, on submission, then puts that input into the database.

I can do that, no problem.

What I want is for the text box to be able to accept BB code and when the contents of this text box is rendered somewhere, it should render it as HTML.

I vaguely remember seeing somewhere how XenForo handles this for posts, but I can't remember for the life of me where.
 

Jake Bunce

XenForo moderator
Staff member
#2
That is done in the view. See this class for a code example:

XenForo_ViewPublic_Thread_View

There is a helper and everything.
 

Chris D

XenForo developer
Staff member
#3
Thank you Jake,

I'm struggling a little bit on this one :(

I might have implemented it wrong, but I'm getting:

Code:
An exception occurred: Undefined index: message in C:\wamp\www\library\XenForo\ViewPublic\Helper\Message.php on line 19
Which kinda makes sense because it's not a message I'm trying to view.

Although not exactly what I'm trying to achieve, I guess the way I'm thinking about it is if you consider Kier's old scratchpad add-on:

http://xenforo.com/community/attachments/scratchpad-0-2-zip.6314/

What I want to do is whatever you'd need to do for that text input box to accept and then render BB Code.