MyBB Community Forums

Full Version: Getting a post body as html with php?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have a thread where all the moderators on the forum keep the rules up to date. However, I would like to also have those rules on a different webpage that is not within the forum. How can I use PHP to get just the body text with the formatting?

Thanks!
<?php
define("IN_MYBB", 1);
require_once "path_to_forum/global.php";
require_once MYBB_ROOT .  "/inc/class_parser.php";
$parser = new PostParser();
$parser_options = array(
"allow_html" => 0,
				"allow_mycode" => 1,
				"allow_smilies" => 1,
				"allow_imgcode" => 1,
				"allow_videocode" => 0,
				"filter_badwords" => 1
			);
$pid = x; /* Change this to the id of the post */
$query = $db->simple_select("posts", "message", "pid=$pid");
$result = $db->fetch_array($query);
$message = $parser->parse_message($result['message'], $parser_options);
echo $message;
?>
(2014-09-28, 11:33 PM)dragonexpert Wrote: [ -> ]
<?php
define("IN_MYBB", 1);
require_once "path_to_forum/global.php";
require_once MYBB_ROOT .  "/inc/class_parser.php";
$parser = new PostParser();
$parser_options = array(
"allow_html" => 0,
				"allow_mycode" => 1,
				"allow_smilies" => 1,
				"allow_imgcode" => 1,
				"allow_videocode" => 0,
				"filter_badwords" => 1
			);
$pid = x; /* Change this to the id of the post */
$query = $db->simple_select("posts", "message", "pid=$pid");
$result = $db->fetch_array($query);
$message = $parser->parse_message($result['message'], $parser_options);
echo $message;
?>

Perfect! Thank you!