MyBB Community Forums

Full Version: Parsing BB code on my site
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I am using a simple statement to get all the replies of a thread with tid = 20. But when I use the statement, my messages all come as

[b]text here blah blah[/b] [img]image url[/img]

I want to parse the BBcode so that the text is actually bolded and the image is shown. How do I do this?
If you want to parse a post just look at the mybb does it, if it isn't inside a page of mybb include 'inc\class_parser.php' and create a new instance of the parser ($parser = new postParser; ).

Then you can do something like:
$post['message'] = $parser->parse_message($post['message'], $parser_options);

$parser_options tells if to allow smiles and html etc...
I'm getting this error and I don't know how to fix it.

Fatal error: Call to a member function on a non-object in /home/forums/inc/class_parser.php on line 357
the line is:
$smilies = $cache->read("smilies");

I'm understand that you do that outside of mybb... the $cache isn't initialized

If you want parts of MyBB to work in your custom page, you'll probably need to include '/inc/init.php' OR '/global.php' and put the following 'define's according to your needs (you don't must to put all of them) :
// the well known IN_MYBB for public pages
define("IN_MYBB", 1);

// If you don't want visits here showing up on the Who's Online
define("NO_ONLINE", 1);

// if you don't need plugins in your page
define("NO_PLUGINS");