Parse bbCode direct from the database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dygear
    New Member
    • Nov 2006
    • 15
    • 4.1.x

    Parse bbCode direct from the database.

    The front page of a website I am working on happens to update it's self from a forum post. These post can contain bbCode, and I would like to know how to parse the vBBBcode with out having to make my own parser. Seeing as the one in vB is updated, and there is no real reason why I should not be able to just include built in parser and go.


    Minus all of the errors of course.

    Originally posted by WLVAC Test Site
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2208
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2229
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2239
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2249
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2259
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2290
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2312
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2367
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2380
    Notice: Trying to get property of non-object in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2392
    Fatal error: Class 'vBulletinHook' not found in C:\wamp\www\wlvac\forum\includes\class_bbcode.php on line 2405
    I've included only the class_bbcode.php file, and the file that is calling it looks like this.

    PHP Code:
        require_once(dirname(__FILE__).'/../forum/includes/class_bbcode.php');
        
    $vB = new vB_BbCodeParser($vbulletinfetch_tag_list()); 
    So, is there a standalone vBBBCode parser? Instead of having to jump through all of these hoops?
    -- Lt. Mark 'Dygear' Tomlin (2923);
  • zappsan
    Senior Member
    • Sep 2004
    • 1143
    • 3.8.x

    #2
    Did you take a look at this? It explains everything.


    You forgot the & in front of the new, you also should include the global.php file.
    This code worked fine for me:
    PHP Code:
    include('./global.php');
    $text='[b]hello[/b] world';
    require_once(
    getcwd().'/includes/class_bbcode.php');
    $parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
    $content $parser->do_parse($text); 
    echo 
    $content
    Output:
    hello world
    *Insert text here* :)

    Comment

    • Dygear
      New Member
      • Nov 2006
      • 15
      • 4.1.x

      #3
      Originally posted by zappsan
      Did you take a look at this? It explains everything.


      You forgot the & in front of the new, you also should include the global.php file.
      This code worked fine for me:
      PHP Code:
      include('./global.php');
      $text='[b]hello[/b] world';
      require_once(
      getcwd().'/includes/class_bbcode.php');
      $parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
      $content $parser->do_parse($text);
      echo 
      $content
      Output:
      Thank you.
      Last edited by Dygear; Sat 26 Apr '08, 6:30pm. Reason: Added 'stack' trace setup.
      -- Lt. Mark 'Dygear' Tomlin (2923);

      Comment

      • Dygear
        New Member
        • Nov 2006
        • 15
        • 4.1.x

        #4
        Sorry for the bump, I just wanted to post a definitive answer to this question as it seems to keep on coming up.

        PHP Code:
        <?php

            
        # Defines the CWD Varable - Modify this varable to point to the forum root.
            
        define('CWD'getcwd() . '/forum');
            
        # Loads global varables and required files. (Gives us access to $vbulletin);
            
        include(CWD '/global.php');
            
        # Loads the vB_BbcodeParser class and the fetch_tag_list function.
            
        require_once(CWD '/includes/class_bbcode.php');
            
        # Creats the BBCode Parser, $vbulletin comes from init.php on line 49, fetch_tag_list() comes from 
            
        $vBBCode =& new vB_BbcodeParser($vbulletinfetch_tag_list());
            
        # Echos out the parsed (HTML) version of the BBCode below.
            
        echo $vBBCode->do_parse('[b]BBCode[/b] [i]Parsed[/i] [u]Text[/u]');

        ?>
        Last edited by Dygear; Tue 3 Feb '09, 6:31am.
        -- Lt. Mark 'Dygear' Tomlin (2923);

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...