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
  #62  
Old 09-05-2008, 03:53 AM
hellbringer80 hellbringer80 is offline
 
Join Date: Jul 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow great man, thanks, very useful!
Reply With Quote
  #63  
Old 09-26-2008, 10:58 AM
tuursw tuursw is offline
 
Join Date: Sep 2008
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i want to use a script outside of the folder where the forum is installed, but when i include the global.php with "require_once('forum/global.php');" the my script doesn't works anymore..?

Do i need to include anything else which has the reference to the folder or so?

(when i put my script in the forum folder is seems to work fine)
Reply With Quote
  #64  
Old 10-12-2008, 10:52 AM
BlackxRam BlackxRam is offline
 
Join Date: Aug 2003
Posts: 364
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

in 3.6 how can I get BBcode and Line Breaks to work properly in the Profile Pages? Especially in Custom Fields?
Reply With Quote
  #65  
Old 02-28-2009, 09:27 AM
MTGDarkness MTGDarkness is offline
 
Join Date: Dec 2008
Posts: 270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Two questions.
1. Does this work with 3.7.x?
2. What's the right syntax to make $text the combination of three variables? I have this right now:
Code:
if ($post[field11] && $post[field12])
{
require_once(DIR . '/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);  

$text = $post[field11].$message.$post[field12];
}
And in the postbit template, I intend to use a conditional to replace $message with $parsed_text if both fields are filled in. However, the message comes up as blank. I checked the source code and came up with just the start of the post div. I'm guessing it's because my syntax is wrong; specifically
Code:
$post[field11].$message.$post[field12]
Reply With Quote
  #66  
Old 11-21-2009, 10:48 AM
Fox Mc Cloud Fox Mc Cloud is offline
 
Join Date: Oct 2006
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas View Post
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.
Thanks, that was what I needed
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:01 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.04660 seconds
  • Memory Usage 2,265KB
  • Queries Executed 22 (?)
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
  • (2)bbcode_code
  • (2)bbcode_php
  • (1)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
  • (2)pagenav_pagelink
  • (6)post_thanks_box
  • (1)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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