Hi all,
I'm trying to call postParser from my main website code, and it's working by-and-large. I'm initializing like this:
if (!defined('MYBB_ROOT')) { define('MYBB_ROOT', $forum_path); }
global $mybb;
define('IN_MYBB', NULL);
require_once($forum_path.'inc/init.php');
require_once($forum_path.'inc/class_parser.php');
and then calling like this:
$parser_options = [];
$parser_options['allow_html'] = 1;
// $parser_options['allow_mycode'] = 1;
$parser_options['allow_smilies'] = 1;
$parser_options['allow_imgcode'] = 1;
$parser_options['allow_videocode'] = 1;
$parser_options['filter_badwords'] = 1;
$parser = new postParser;
// select message from mybb_gtgg_posts
$parser->parse_message($message, $parser_options);
... and this works, except of course for translating "mycode" segments. If I uncomment the 'allow_mycode' line, then the parser returns an empty string.
edited:
It looks like that is happening because mybb settings aren't initialized, e.g. in function cache_mycode:
if($mybb->settings['allowbasicmycode'] == 1)
I added:
global $mybb;
... and then printed out $mybb. It looks like $mybb is being initialized correctly, and allowbasicmycode is set to 1.
So, the question is, am I missing some initialization required to make parse_message work for mycode?
Thanks,
--Dave
I'm trying to call postParser from my main website code, and it's working by-and-large. I'm initializing like this:
if (!defined('MYBB_ROOT')) { define('MYBB_ROOT', $forum_path); }
global $mybb;
define('IN_MYBB', NULL);
require_once($forum_path.'inc/init.php');
require_once($forum_path.'inc/class_parser.php');
and then calling like this:
$parser_options = [];
$parser_options['allow_html'] = 1;
// $parser_options['allow_mycode'] = 1;
$parser_options['allow_smilies'] = 1;
$parser_options['allow_imgcode'] = 1;
$parser_options['allow_videocode'] = 1;
$parser_options['filter_badwords'] = 1;
$parser = new postParser;
// select message from mybb_gtgg_posts
$parser->parse_message($message, $parser_options);
... and this works, except of course for translating "mycode" segments. If I uncomment the 'allow_mycode' line, then the parser returns an empty string.
edited:
It looks like that is happening because mybb settings aren't initialized, e.g. in function cache_mycode:
if($mybb->settings['allowbasicmycode'] == 1)
I added:
global $mybb;
... and then printed out $mybb. It looks like $mybb is being initialized correctly, and allowbasicmycode is set to 1.
So, the question is, am I missing some initialization required to make parse_message work for mycode?
Thanks,
--Dave