vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   bb-codes on external page (https://vborg.vbsupport.ru/showthread.php?t=228670)

burn4cid 11-23-2009 10:44 AM

bb-codes on external page
 
Hi,

Im making a site with a vbulletin forum attached, but topics for a specified forum are displayed on the site as news.

But i need a way to convert the BB-codes from the database.
Is there some sort of code of script i can use or can i attach a script forum vbulletin it self

Greetings burn

kh99 11-23-2009 12:55 PM

Something like this?

Code:

require_once(DIR . '/includes/class_bbcode.php');

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

$text = "[color=red]some text with tags[/color]";
$html = $bbcode_parser->parse($text);


burn4cid 11-23-2009 03:08 PM

i have this:

PHP Code:

<?php

define
('CWD''/home/egconline/domains/xxx/public_html/forum');
include(
CWD '/global.php');
require_once(
CWD '/includes/class_bbcode.php');

    
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$parsed_text $parser->do_parse(viewrules(2322));  
     echo(
$parsed_text);


?>

viewrules(2322) = the function that gets the post text form the db

but then i recieve this error:
Quote:

Fatal error: Call to a member function query_read_slave() on a non-object in /usr/home/egconline/domains/xxx/public_html/forum/includes/class_bbcode.php on line 208

kh99 11-23-2009 03:22 PM

Hmm...I tried this:

Code:

<?php

require_once('./global.php');
require_once(DIR . '/includes/class_bbcode.php');

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

$text = "[color=red]some text with tags[/color]";
$html = $bbcode_parser->parse($text);

echo $html;

?>


In a .php file in the forum directory, but it only works when I'm logged in and the cookies have already been set.

Maybe someone else can tell us what's going on...


(stuff deleted because none of it made sense...)

burn4cid 11-23-2009 04:08 PM

im not working in the same folder, and its not supposed to be logged in.

Im working form a other subdomain.

PHP Code:

<?php

chdir
('/home/egconline/domains/egc-online.com/public_html/forum');
include (
'./global.php');
require_once (
DIR '/includes/class_bbcode.php');

chdir('/home/egconline/domains/egc-online.com/public_html/v2');

function 
maintext()
{
    
$bbcode_parser = &new vB_BbCodeParser($vbulletinfetch_tag_list());

    
$text viewrules(2322);
    
$html $bbcode_parser->do_parse($text);

    echo 
$html;
}

include (
"template.php");

?>

gives the same problem

kh99 11-23-2009 04:38 PM

FWIW, my problem with not being logged in is fixed by calling "print_ouput" instead of "echo". I put my test program in another directory and added the chdir:

PHP Code:

<?php

chdir
('/home/???/forum');
require_once(
'./global.php');
require_once(
DIR '/includes/class_bbcode.php');

$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());

$text "[noparse][color=red]some text with tags[/color][/noparse]";
$html $bbcode_parser->parse($text);

print_output($html);

?>

Still works OK.

Maybe you just need a "global $vbulletin;" in your maintext()? (but you didn't have it in a function before, so maybe not...)

--------------- Added [DATE]1259002914[/DATE] at [TIME]1259002914[/TIME] ---------------

Something else that maybe should be mentioned (for future reference if not for burn4cid) - there are other php BBCode parsing functions available out there, if you don't need to specifically use the vBulletin codes.

burn4cid 11-23-2009 08:06 PM

OMG you r right $vbulletin needs to be added global :D

ty

Citizen Bleys 04-15-2010 08:29 AM

Hate to bump an old thread, but I'm in exactly the same boat. I want to pull posts from my vBulletin to my frontsite; the self-authored PHP script I'm using is in / and my vBulletin is in /forums/

I've already written all of the code necessary to display forum posts from my news forum as news updates, the only things that I haven't got working are parsing BB code and newlines and truncating long posts.

I've tried the code posted in this thread and a few other variants.

Code:

require_once(DIR . '/includes/class_bbcode.php');
says that /DIR/includes/class_bbcode.php does not exist. No, I did not enclose DIR in quotes. I've tried it both adding /forums to the beginning and chdir'ing to forums.

Code:

require_once('./includes/class_bbcode.php');
This at least finds the file (as does using the FQDN), if I chdir to my /forums directory (and hopefully remember to chdir back after!) -- BUT! all it does is throw up an error:

Code:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /(elided)/forums/includes/class_bbcode.php on line 166
include()ing global.php also throws an error:

Code:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /(elided)/forums/includes/class_bootstrap.php on line 26
An attempt to require_once class_bbcode in a global scope functions, but if I try to instantiate a new vB_BbCodeParser in a while loop, I get

Code:

Fatal error: Cannot instantiate non-existent class: vb_bbcodeparser in /(elided)/main.php on line 135

Marco van Herwaarden 04-15-2010 11:35 AM

Start by checking the following 2 conditions:
- You must chdir() to the vBulletin installation directory before calling any of the vBulletin scripts.
- global.php should be the first to be included.

kh99 04-15-2010 11:43 AM

Quote:

Originally Posted by Citizen Bleys (Post 2021559)
Code:

require_once(DIR . '/includes/class_bbcode.php');
says that /DIR/includes/class_bbcode.php does not exist. No, I did not enclose DIR in quotes. I've tried it both adding /forums to the beginning and chdir'ing to forums.

I think this is because 'DIR' is not defined, it's normally defined in includes/init.php. One of your errors is in class_bootstrap.php, are you working with a 4.0 version?

(ETA: I was in the middle of writing my post when Marco posted - you should probably just follow his instructions)


All times are GMT. The time now is 04:34 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01044 seconds
  • Memory Usage 1,758KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete