How to use Invision’s BBCode

Using Invision’s BBCode isn’t straight forward. Chances are that you need to invoke the BBCode parser if you want to create a plugin or hook for Invision Powered Board. Here’s the rough code to do so, with $topics being the array containing all the topics from the database to be parsed:

[code lang=”php”]setAllowHtml( 1 );
//—————————————–
// Return the data
//—————————————–
foreach ($topics as &$topic) {
$topic[“formattedPost”] = $editor->process($topic[“post”]);
IPSText::getTextClass(“bbcode”)->parsing_section = “topics”;
IPSText::getTextClass(“bbcode”)->parse_smilies = TRUE;
IPSText::getTextClass(“bbcode”)->parse_bbcode = TRUE;
IPSText::getTextClass(“bbcode”)->parse_html = FALSE;
IPSText::getTextClass(“bbcode”)->parse_nl2br = TRUE;
IPSText::getTextClass(“bbcode”)->bypass_badwords = FALSE;
$topic[“formattedPost”] = IPSText::getTextClass(“bbcode”)->preDisplayParse( $topic[“formattedPost”] );
}
?>[/code]

For the parsing_section, you should put a value that corresponds to the editor section. In my case, I need it to ‘topics’. To get the full list, you may need to look up Invision Powered Board’s source code which I cannot provide.

I wrote this down more as a personal note and I hope it benefits you as it did for me. If you have any questions, feel free to post and I can attempt answering.