The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Parsing BBCodes on an external page
Originally taken up in a borrowed thread
Basics: I want to write a script that copies the text of threads from my news forum to my front site. I've hand-coded a mostly-working script from scratch, but I have no idea how to parse BBCodes, so any multiline news posts or posts that contain BBCodes show up as a giant mishmash on the front site. My front site is in / and the forums are in /forums/, so I have to chdir() into forums and back whenever I want to call any vBulletin functionality. Having searched the forums, I've seen code that looks like this: PHP Code:
Problem is, it doesn't work. The other thread in the vB3 forum solved most of the initial issues I had, so I'll leave them out, but now I'm running into some dependency problems. I'm not all that familiar with the internal workings of vBulletin--for that matter, OOP in general is not my forte--so I don't know what classes/methods/functions are where. Here's my current code: PHP Code:
With that code in the while loop, I get the following error: Code:
Fatal error: Call to a member function query_read_slave() on a non-object in /(elided)/forums/includes/class_bbcode.php on line 220 If it matters, the basic structure of my frontsite is as follows frontconfig.php: contains global variables for my code -- nothing relating to vBulletin index.php: Shell HTML page containing the CSS and basic table structure -- a vanilla site with a sidebar containing links and a main page body containing news posts sidebar.php: Links, inserted into index.php with an include() statement main.php: contains some static HTML and my news script. /forums/global.php is include()d at the top of index.php; since main.php is called only from within index.php, it should always include global.php. There's also a "global vbulletin;" statement in index.php which should likewise be inherited into main. |
#2
|
|||
|
|||
You should reread Marco's post in the other thread you posted in. You need to chdir before you include the forum files.
From your script and what you said it looks like you require the global higher up before you chdir to the forum. |
#3
|
|||
|
|||
You might find it easier to do this whole thing with an RSS feed grabber or if you have access to it the CMS.
I've personally found chdir to be so irritatingly incosistent when working with vBulletin that I just moved my files top level files into the /Forum/ folder and then just set my top-level .htaccess to show /Forum/filename.php as the main page. |
#4
|
|||
|
|||
Quote:
Quote:
|
#5
|
|||
|
|||
Update: I tried to play with this in a separate script that does nothing but parse, hoping to encapsulate it in a function and call it in my main script.
This works (full script) PHP Code:
PHP Code:
The output is: Code:
Fatal error: Call to a member function query_read_slave() on a non-object in /(elided)/forums/includes/class_bbcode.php on line 220 Since it works unencapsulated, I think this has just become a pure PHP question instead of vBulletin-specific, let alone version specific. |
#6
|
|||
|
|||
Quote:
Also, with your function on the following post, it is not quite right, there are a few things wrong. You need to set vbulletin as global in the function, you're not returning the text and you are not passing the variable into the function to be parsed. PHP Code:
|
#7
|
|||
|
|||
Now we're getting somewhere! OK, the standalone test works; I couldn't get it working in my main page so I started doing some trial and error. I wrote the parseMe() function at the very top of index.php right after calling global.php. It tested OK everywhere in index.php up until I called main.php. Just to be sure, I called parseMe() right before include('main.php') and it worked, but it failed right after.
I started moving down main.php until I found the code causing the failure: PHP Code:
EDIT: More "This makes no sense" -- I tried switching to MySQLi instead and commented out the whole if statement above. This, placed directly below the above (commented out) code fails: PHP Code:
PHP Code:
Code:
Fatal error: Call to undefined method mysqli::query_read_slave() in /homepages/32/d89350510/htdocs/forums/includes/class_bbcode.php on line 220 I eventually got my script working BUT I sure would like to know why I have to call a function for no reason in the middle of my script EDIT: Spoke too soon -- as soon as I use a Quote tag in any of my posts, the frontsite script crashes with this error: Code:
Fatal error: Call to undefined method mysqli::query_read_slave() in /homepages/32/d89350510/htdocs/forums/includes/functions.php on line 3912 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|