Using xenforo post parser outside xenforo?

Member 3639

Active member
Okay so i am looking into the post parser at the moment.

After including the file how do i run my own text through it? For example loading a post outside the forum and parsing it? Which functions do i need to pass it through?
 
Assuming you already have the XenForo_* classes available (via autoloading setup - see index.php/admin.php for examples in bootstrapping).

PHP:
$formatter = XenForo_BbCode_Formatter_Base::create();
$parser = new XenForo_BbCode_Parser($formatter);
$html = $parser->render($text);
 
It's odd in a test.php file i have this:
PHP:
<?php
$startTime = microtime(true);

$xenforoRoot = '/home/prxainf1/public_html/gamingonlinux.info/chill';
require($xenforoRoot. '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($xenforoRoot . '/library');

XenForo_Application::initialize($xenforoRoot . '/library', $xenforoRoot);
XenForo_Application::set('page_start_time', $startTime);

$formatter = XenForo_BbCode_Formatter_Base::create();
$parser = new XenForo_BbCode_Parser($formatter);

$text = "[b]test[/b]";
$html = $parser->render($text); 

echo $html;
?>

Which works fine, but when i put the main parts into a header.php file for my main site i get an unexpected error message crop up with no other details.
 
Can you enable error reporting in that file to get a better description of the issue? Are you trying to integrate it with an existing software?
 
Top Bottom