Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 16 Jun 2007, 17:47
weicool weicool is offline
 
Join Date: Dec 2006
Parsing BBCode to HTML

Hey everyone,

I'm currently pulling the latest posts from one of my forums directly from the database and putting it on my main site (non-vB).

However, unsurprisingly, there is a bunch of BBCode mixed within the text (the pagetext column of the post table). How can I parse this BBCode to return HTML? Which vB file must I include and which function should I use?
Reply With Quote
  #2  
Old 17 Jun 2007, 01:07
Brad's Avatar
Brad Brad is offline
 
Join Date: Nov 2001
Real name: B-rad
This should be all you need;


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #3  
Old 17 Jun 2007, 07:31
weicool weicool is offline
 
Join Date: Dec 2006
Originally Posted by Brad View Post
This should be all you need;


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
Thanks a lot!

However, when I tried to do that, I get this error message:

Fatal error: Class 'vBulletinHook' not found in /mnt/w0800/d09/s41/b027ae64/www/forums/includes/class_bbcode.php on line 2347

Looking at the code in class_bbcode.php, it seems to abruptly call on a vBulletinHook without ever declaring it. I'm very new to PHP...

What would be the problem here?
Reply With Quote
  #4  
Old 17 Jun 2007, 07:52
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
You'll need to have this above that code:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #5  
Old 17 Jun 2007, 17:49
weicool weicool is offline
 
Join Date: Dec 2006
Almost seems to work...but still a little error:

$bbcode =& new vB_BbCodeParser($vbulletin, fetch_tag_list());

That line seems to be problematic.

I get the following error message:

Fatal error: Call to a member function query_read_slave() on a non-object in /mnt/w0800/d09/s41/b027ae64/www/forums/includes/class_bbcode.php on line 198
Reply With Quote
  #6  
Old 18 Jun 2007, 19:25
weicool weicool is offline
 
Join Date: Dec 2006
Can someone please give me the last bit of information I need to get this thing working...?
Reply With Quote
  #7  
Old 03 Sep 2007, 02:23
Augusto Augusto is offline
 
Join Date: Dec 2006
here's a working sample of it that works in the forum installation directory:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

save it as "testparser.php" and simply run it in your forum installation directory as www.yourforum.com/forum/testparser.php

it should print this: "Some text with bbcode in it"
Reply With Quote
  #8  
Old 05 Sep 2007, 10:30
XManuX XManuX is offline
 
Join Date: Feb 2007
I'm having exactly the same error message :

Fatal error: Call to a member function on a non-object in /path/class_bbcode.php on line 198

I'm trying to acheive the same thing : parsing bbcodes in posts that i am currently displaying outside the forum (non-vb.)

my code is :

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

no errors displayed since i added the last line

@Augusto : i tried your test successfully.

Last edited by XManuX : 05 Sep 2007 at 10:52.
Reply With Quote
  #9  
Old 09 Nov 2007, 03:39
dolbex dolbex is offline
 
Join Date: Aug 2005
I am still having a really tough time with pulling this off in 3.6. I continue to get the error:

Fatal error: Call to a member function query_read_slave() on a non-object in /var/www/newspail3/forums/includes/class_bbcode.php on line 213

from outside the forum directory.

--------------- Added 09 Nov 2007 at 10:46 ---------------

Figured this out.

I had these examples embedded within functions. I don't quite understand why they wouldn't work but I assigned $bbcode when I was inside my forum directory


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I then passed $bbcode into the function and that worked.

Last edited by dolbex : 09 Nov 2007 at 10:46. Reason: Auto-Merged DoublePost
Reply With Quote
  #10  
Old 09 Jun 2009, 05:16
jonbach jonbach is offline
 
Join Date: Nov 2008
I can confirm the last post. This method does not work when part of a function, which is a big problem when integrating into some existing sites.

This works:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This does NOT work:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The errors I get when I try the second code are:
Warning: array_keys() [function.array-keys]: The first argument should be an array in [path]/includes/functions.php on line 4227

Warning: Invalid argument supplied for foreach() in [path]/includes/functions.php on line 4227

Fatal error: Call to a member function query_read_slave() on a non-object in /mypath/includes/functions.php on line 3189
I have plenty of experience in PHP, but I haven't encountered a problem like this before. I really would prefer to not have to hack this together by hard coding the conversion code everywhere I need it. Does anyone have any ideas on why it breaks when within a function?
Reply With Quote
  #11  
Old 09 Jun 2009, 07:49
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
global.php cannot be included outside of global scope.
__________________
View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #12  
Old 11 Aug 2009, 22:40
vcor vcor is offline
 
Join Date: Mar 2008
Originally Posted by Dismounted View Post
global.php cannot be included outside of global scope.
Could you explain that a bit more? I'm good with PHP, but never seen this kind of problem before. Does this mean global.php has to be modified to work from functions? Hopefully not, as I suspect it's a big task.

Likely should be another thread, but I also get identical the error:
Fatal error: Call to a member function query_read_slave() on a non-object in /mypath/includes/functions.php on line 3189

This error has only started to appear over the last few weeks (with v3.8.3), and I've not made any code changes, nor have I seen this error in the last year or so (I carefully track PHP errors).

Similar to jonbach's function, I use a function to handle creating threads:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This has been working perfectly for quite a while (many vBulletin versions over a year or so), so it's also puzzling why it's worked before and lately generates errors.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 20:59.

Layout Options | Width: Wide Color: