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
  #32  
Old 11-26-2005, 06:01 AM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Someone, anyone, PLEASE help ....
Reply With Quote
  #33  
Old 11-26-2005, 11:32 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by noonespecial
I've been trying to get this to work in the member.php file so that bbcode will be parsed for user profiles --

PHP Code:
require_once('./includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
$profilefield['value'] = $parser->do_parse($profilefield['value']); 
Just isn't working though.
Works fine. Though, for performance reasons I would split it into 2 Plugins.
Reply With Quote
  #34  
Old 11-27-2005, 12:35 PM
Kristoph Kristoph is offline
 
Join Date: Mar 2004
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

just a quick one... got this working great for including posts on my front page, but it is trying to find the smilies in /images/smilies, when infact they're in /community/images/smilies....

is there a quick fix around this built into the vbcodeparser class? or should I just use str_replace on the outputted string?

cheers!
Reply With Quote
  #35  
Old 12-08-2005, 05:07 AM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone know any way to parse $thread[preview] - I can't figure out where or how to do it for the life of me. It's in functions_forumdisplay.php ..

Found it. Much easier then I thought.
Reply With Quote
  #36  
Old 12-14-2005, 06:45 PM
Ratchet Ratchet is offline
 
Join Date: May 2002
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Kristoph
just a quick one... got this working great for including posts on my front page, but it is trying to find the smilies in /images/smilies, when infact they're in /community/images/smilies....

is there a quick fix around this built into the vbcodeparser class? or should I just use str_replace on the outputted string?


cheers!
I just used str_replace as you mentioned. Seemed easy. Something like this should work:
Code:
$parsed_text = str_replace("images/smilies","community/images/smilies",$parsed_text);
As an aside, I couldn't get this code working either until I replaced do_parse() with parse(). Dunno what the difference is.
Reply With Quote
  #37  
Old 12-15-2005, 04:49 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a custom bbcode [mp3] [/mp3] which shows an inline media player. I have struggled with this for hours but cannot come up with a solution to make it so only registered members can see it. All I really need is to prevent guest from viewing it.
Reply With Quote
  #38  
Old 01-07-2006, 07:17 AM
SHANE-D-PAIN's Avatar
SHANE-D-PAIN SHANE-D-PAIN is offline
 
Join Date: Sep 2003
Location: Sheffield, Uk
Posts: 140
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is so frustrating. I am trying to create a plugin that will parse html in certain userinfo fields.

So far I have this as a plugin in member_complete:
PHP Code:
if ($userinfo['field1']) 

if (!
is_object($bbcode_parser)) 



 require_once(
'./includes/class_bbcode.php'); 
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list()); 
$userinfo['field1'] = $bbcode_parser->do_parse($userinfo['field1'], truetruetruetruetruetrue); 

Any ideas?
Reply With Quote
  #39  
Old 01-08-2006, 07:59 AM
Oreamnos's Avatar
Oreamnos Oreamnos is offline
 
Join Date: Dec 2004
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SHANE-D-PAIN
This is so frustrating. I am trying to create a plugin that will parse html in certain userinfo fields.

So far I have this as a plugin in member_complete:

Any ideas?
this might help: https://vborg.vbsupport.ru/showthread.php?t=103460
Reply With Quote
  #40  
Old 01-17-2006, 07:10 PM
bigtime bigtime is offline
 
Join Date: Jun 2002
Location: Houston, Texas
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

The following code will display posts on a non forum page in the home directory. However, when I try to parse the bbcode it doesn't work.

Any ideas?

PHP Code:
<?
chdir('./deluxeforums'); 
require("./global.php"); 
require_once("./includes/class_bbcode.php"); 
require_once("./includes/config.php");


    $num_active = 5;
    $num_topicchars  = 110;

     $db=mysql_connect("$host","$user","$pass");
    mysql_select_db("$dbname");

    $querylatest="select * from thread where forumid='1' or forumid='2' or forumid='3' or forumid='4' or forumid='5' or forumid='6' or forumid='7' or forumid='10' or forumid='11' or forumid='12' or forumid='13' or forumid='14' or forumid='15' or forumid='16' or forumid='17' or forumid='18' or forumid='19' or forumid='20' or forumid='22' or forumid='23' or forumid='25' or forumid='26' or forumid='27' or forumid='28' or forumid='29' or forumid='30' or forumid='31' or forumid='32' or forumid='34' or forumid='35' or forumid='36' or forumid='37' or forumid='38' order by lastpost desc limit $num_active";

    $resultlatest = mysql_query($querylatest,$db);

?>
<style type="text/css">
<!--
.style2 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 9px;
}
-->
</style>
<table width="100%" align="center" cellpadding="2" cellspacing="0">
  <?

    while ($latest_array = mysql_fetch_array($resultlatest)) {

    // Get Forum Infomation
    $query_forum = "select * from forum where forumid='$latest_array[forumid]'";
    
    $result_forum = mysql_query($query_forum,$db);
    $forum_info_array = mysql_fetch_array($result_forum);

        // split the date up a bit
        $datestr1 = substr($latest_array["dateline"],0,10);
    $datetime = substr($latest_array["dateline"],11,8);


?>
  <tr>
    <td align="left"><b><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#335980"><? echo $forum_info_array["title"]; ?></font>:<br>
            <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><? echo $latest_array["title"]; ?></font></b></td>
  </tr>
  <?
    $querythread="select * from post where threadid='$latest_array[threadid]' order by dateline desc limit 1";

    $result_thread_text= mysql_query($querythread,$db);

    $result_thread_array = mysql_fetch_array($result_thread_text);


    $pagetext = substr(strip_tags($result_thread_array[pagetext]),0,$num_topicchars);



//parse bbcode...
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list()); 
$pagetext = $parser->do_parse($pagetext);  



    ?>
  <td width="100%"><p align="left"><img src="/deluxeforums/images/statusicon/forum_new.gif"> <span class="style2"><? echo "$pagetext"; ?>... <a href="/deluxeforums/showthread.php?threadid=<? echo "$latest_array[threadid]"; ?>">(more)</a></span></p>
          <p align="left"><span class="style2">Started By: <? echo "$latest_array[postusername]"; ?> <br>
        Last Post By: <? echo "$latest_array[lastposter]"; ?> </span></p><hr align="center" width="80%">
      </td></tr>
 <?
}
?>
</table>
Reply With Quote
  #41  
Old 03-13-2006, 09:48 PM
DrewM DrewM is offline
 
Join Date: Oct 2005
Posts: 564
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why won't this work I'm trying to make it parse my page stuff it's loading it form the db and it just won't parse my php code is:
PHP Code:
<?php
error_reporting
(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT''News'); 
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array(
        
'site_page',
        
'News_view',
);
$actiontemplates = array();
 
chdir('/home/rdsx667/public_html/forum/');
require_once(
'./global.php');
require_once(
DIR '/includes/class_bbcode.php'); 

$headinclude str_replace('clientscript'$vbulletin->options['bburl'] . '/clientscript'$headinclude);
$navbits = array(); 
$navbits[$parent] = '';
$navbits construct_navbits($navbits);


    

    
if (
$_REQUEST['do'])
{
$call $_REQUEST['do'];
$Feed $db->query_first("select * from " TABLE_PREFIX "page where page_id = " intval($call));
$pagename $Feed['page_name'];
$text $Feed['page_contents'];
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list()); 
$pagecontents $parser->do_parse($text$do_html$do_smilies$do_bbcode$do_imgcode$do_nl2br$cachable);
eval(
'print_output("' fetch_template('site_page') . '");');
}


eval(
'$navbar = "' fetch_template('navbar') . '";');    


?>
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 08:51 AM.


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.05132 seconds
  • Memory Usage 2,346KB
  • Queries Executed 27 (?)
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
  • (5)bbcode_php
  • (3)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
  • (4)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_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