Requested tutorial: creating a BBCode with a PHP Callback

ForestForTrees

Well-known member
In a thread, a while ago, @katsulynx wrote,
When I interpret the description (This callback will receive these parameters: array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter.) correct, the Php class gets those three parameters handed over. So I guess it needs to take them as input logically, but which of them exactly includes which details?
I've looked all around, but I can't see an answer to that question. If anyone is up for making a tutorial on this in the resource manger in the Tips and Guides section, I bet it will get a lot of positive votes. It's core functionality and a lot of people might know how to write PHP, but might not know how to use $rendererStates or $formatter. I know I would!

Even just having some example code with a couple of comments would be huge if someone has written one of these and has it hanging around. Add in a screenshot from the ACP, and you have a pretty solid contribution to the "Tips and Guides" section of the RM.
 
You can include the print_r($tag) and print_r($rendererStates) in your callback, to get the content of the first two variables printed out at the to of your page (unformatted but readable) for programming/debugging purpose. Genereally said, $tag seems to include the BBCode-Tag given and the text in between or an iterative stack of more children-tags if there are some nad $rendererStates seems to hold some settings of something. Haven't found out what the last one is though.
 
I really would need some help to get started.. a tiny addon or something that I could look at on how they do it... just as long as it uses the php callback. I have php code I need to use for my bbcodes but haven't got a clue on how to get started with the actual addon or class I need to create.
 
Back
Top Bottom