Not Solved [Error Message] BBCodes on website
#1
Not Solved
I've developed a 'thread-displayer' that I'm currently using on my frontpage. It's working fine.
But my question is - How can I make the BBCodes work? It works fine on the forum, but I guess I need some kind of coding in order to make the BBCodes appear on the frontpage as they do in the actual thread.
I've tried the following:

<?php
$arrayBBCode=array(
    ''=>         array('type'=>BBCODE_TYPE_ROOT,  'childs'=>'!i'),
    'i'=>        array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<i>',
                    'close_tag'=>'</i>', 'childs'=>'b'),
    'url'=>      array('type'=>BBCODE_TYPE_OPTARG,
                    'open_tag'=>'<a href="{PARAM}">', 'close_tag'=>'</a>',
                    'default_arg'=>'{CONTENT}',
                    'childs'=>'b,i'),
    'img'=>      array('type'=>BBCODE_TYPE_NOARG,
                    'open_tag'=>'<img src="', 'close_tag'=>'" />',
                    'childs'=>''),
    'b'=>        array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<b>',
                    'close_tag'=>'</b>'),
);
$text=<<<EOF
[b]Bold Text[/b]
[i]Italic Text[/i]
[url]http://www.php.net/[/url]
[url=http://pecl.php.net/][b]Content Text[/b][/url]
[img]http://static.php.net/www.php.net/images/php.gif[/img]
[url=http://www.php.net/]
[img]http://static.php.net/www.php.net/images/php.gif[/img]
[/url]
EOF;
$BBHandler=bbcode_create($arrayBBCode);
echo bbcode_parse($BBHandler,$text);
?>


I copied it to test it, but I received an error;
Fatal error: Call to undefined function bbcode_create() in /usr/www/optimuslogin/public/index.php on line 193
Reply
#2
Not Solved
Hi,

You can just use the parser for MyBB, as follows:

<?php

defined('IN_MYBB') or define('IN_MYBB', 1);

require_once './global.php';

if (!isset($parser)) {
    require_once MYBB_ROOT . 'inc/class_parser.php';

    $parser = new postParser();
}

$parsedText = $parser->parse_message($test, array(
    'allow_html' => false,
    'filter_badwords' => true,
    'allow_mycode' => true,
    'allow_smilies' => true,
    'nl2br' => true,
));

This will handle all of the MyCode for you, including any custom MyCode you may have configured.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)