• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Using xenforo post parser outside xenforo?

Member 3639

Active member
#1
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?
 

Indigo

Active member
#2
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);
 

Member 3639

Active member
#3
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.
 

Indigo

Active member
#4
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?