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

Parse Standard BBCode in Custom BBCode Callback


Well-known member
Good evening,

I'm currently working on implementing a custom set of BBCodes, which should allow the user to format their text. However, I don't want to use/can't use a simple replace statement, so I have to do it with a php-callback. So far so good, now to my problem:

I've implemented the callback for so long, but when it comes to the text inside the tag, the normal BBCode, like bold, etc. is not rendered but simply returned as code and therefor printed blank back into the thread view. I guess I have to call the normal XenForo_BbCode_Formatter_Base, but honestly have no idea on how to use it. I'm not even sure if i have to create a new one or use the one handed over with the function call.

Does anyone have a short explanation on how to render the default BBCode in a Custom BBCode callback and/or how to use that formatter?

Basically shown on the example of a table-bbcode, this would be handed over as $tag to the function:
Array ( [tag] => tr [option] => [original] => Array ( [0] => [tr] [1] => [/tr] ) [children] => Array ( [0] => Array ( [tag] => td [option] => [original] => Array ( [0] => [td] [1] => [/td] ) [children] => Array ( [0] => Array ( [tag] => b [option] => [original] => Array ( [0] => [B] [1] => [/B] ) [children] => Array ( [0] => Some Message ) ) ) ) ) )
By processing it, I would work it down the way to call the respective function to work over the td-code and then would be left with the children of those - now including the default BBCode.
Array ( [0] => Array ( [tag] => b [option] => [original] => Array ( [0] => [B] [1] => [/B] ) [children] => Array ( [0] => Some Message ) ) )
If I understood the formatter so far correctly, I can just hand him over the object above (however I have no idea on how to do that), hopefully call a single function and get the respective formatted code back, ready for output - at least that would be the most perfect solution I could think of.