Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Parse BBCode (in 3.5)
Andreas's Avatar
Andreas
Join Date: Jan 2004
Posts: 6,863

 

Germany
Show Printable Version Email this Page Subscription
Andreas Andreas is offline 06-07-2005, 10:00 PM

If you want to parse BBCodes somewhere in your hacks/scripts (assuming that global.php is already required):

PHP Code:
require_once(DIR '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
$parsed_text $parser->do_parse($text$do_html$do_smilies$do_bbcode$do_imgcode$do_nl2br$cachable); 
The parameters for method do_parse() are:
  • $text = Text to be parsed
  • $do_html = Whether to allow HTML or not (Default = false)
  • $do_smilies = Whether to parse smilies or not (Default = true)
  • $do_bbcode = Whether to parse BB code (Default = true)
  • $do_imgcode = Whether to parse the [img] BB code or not, independant of $do_bbcode (Default = true)
  • $do_nl2br = Whether to automatically replace new lines with HTML line breaks or not (Default = true)
    This should be set to false if you allow HTML.
  • $cachable = Whether the post text is cachable or not (Default = false)

All parameters except $text can be omitted and will use the defaults then.
Reply With Quote
  #12  
Old 09-13-2005, 09:07 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And how do you define them?
Reply With Quote
  #13  
Old 09-14-2005, 04:11 AM
KingSpade KingSpade is offline
 
Join Date: Aug 2005
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
And how do you define them?
I must be missing something because I've yet to get this to work for me . I've got the following and I've tried just about all that I can and nothing is working for me. If anyone could help, I'd appreciate it very much.

PHP Code:
        while ($news $db->fetch_array($getnews))
        {

            
$parser =& new vB_BbcodeParser($vbulletinfetch_tag_list(), true);
            
$news['pagetext'] = $parser->parse($news['pagetext'], falsefalsetruefalsetruefalse);

            eval(
'$blogbit .= "' fetch_template('zoom_blogbits') . '";');
        } 
Reply With Quote
  #14  
Old 09-19-2005, 05:05 PM
Brinnie's Avatar
Brinnie Brinnie is offline
 
Join Date: Jul 2005
Location: Louisiana
Posts: 360
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kirby, how would one go about adding this to the FAQ manager?
Reply With Quote
  #15  
Old 10-01-2005, 01:14 AM
CapinPete CapinPete is offline
 
Join Date: Oct 2004
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In my case I had to use the following code:
Code:
GLOBAL $parser;
I am pretty much a php noob and it took me a good hour to figure this out. I guess its because I declared the parser as an object at the beginning of the script. I am using a function that gets the last 10 posts in a forum and displays it as HTML for use on the homepage. As we all SHOULD know, php requires that you declare a variable "global" if its outside your function.
Reply With Quote
  #16  
Old 10-10-2005, 08:52 PM
Man1c M0g's Avatar
Man1c M0g Man1c M0g is offline
 
Join Date: Jan 2004
Location: Portsmouth, UK.
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I've fiddled with all the suggestions here for the last 2 hours and I still can't get anything to work! Here's the errors I get:

Fatal error: Call to a member function on a non-object in /home/httpd/vhosts/biorust.com/subdomains/forums/httpdocs/includes/class_bbcode.php on line 181

Fatal error: Call to a member function on a non-object in /home/httpd/vhosts/biorust.com/subdomains/forums/httpdocs/includes/functions.php on line 4308
Reply With Quote
  #17  
Old 10-10-2005, 09:00 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wrong Thread.
Please post a new Thread in vB 3.5 Modification Questions and attach the Code you are using.
These errors mean that the vBulletin Registry Object ($vbulletin) does not have a valid reference for the database object.
Reply With Quote
  #18  
Old 10-10-2005, 09:09 PM
Man1c M0g's Avatar
Man1c M0g Man1c M0g is offline
 
Join Date: Jan 2004
Location: Portsmouth, UK.
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
Wrong Thread.
Please post a new Thread in vB 3.5 Modification Questions and attach the Code you are using.
These errors mean the the vBulletin Registry Object ($vbulletin) does not have a valid reference for the database object.
Actually... what you just said goes a long way towards solving the problem! Thanks!
Reply With Quote
  #19  
Old 10-19-2005, 04:57 PM
CommuneZoom CommuneZoom is offline
 
Join Date: Sep 2005
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Man1c M0g
Actually... what you just said goes a long way towards solving the problem! Thanks!
Something small I noticed, which is probably more than obvious for those more experienced, although unless I specifically define true or false in the parse line, it will not convert the BBCode.

It will not parse simply by including the variables.
Reply With Quote
  #20  
Old 10-20-2005, 05:28 PM
MetalAges MetalAges is offline
 
Join Date: May 2004
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm trying to get an index page (www.ultimatemetal.com) to work with the same code I used to have. It worked fine in 3.0.7 . The only issue is the bbcode stuff (which is why I am in this thread ). I exchanged the code I had:

require_once('includes/functions_bbcodeparse.php');

with the code at the beginning of this post:

require_once('includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$parsed_text = $parser->do_parse($text, $do_html, $do_smilies, $do_bbcode, $do_imgcode, $do_nl2br, $cachable);;

I get this same error message with both:

Quote:
Fatal error: Call to undefined function: parse_bbcode() in /home/mahke/public_html/index-test.php on line 32
Line 32 is: $articlelength1 = parse_bbcode($articles['pagetext']);

Am I brainfarting on something here?

Quote:
Originally Posted by chanzero
i should note that kirby helped me figure this out by pointing out that i did not definie $do_html, $do_smilies, $do_bbcode, $do_imgcode, etc

thanks kirby!
Maybe this is my issue? Chanzero or anyone else, can you elaborate on how to define this properly?
Reply With Quote
  #21  
Old 10-20-2005, 07:30 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, the parse_bbcode() call needs to be $parser->do_parse() instead
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:54 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05005 seconds
  • Memory Usage 2,318KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (2)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete