Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-23-2009, 10:44 AM
burn4cid burn4cid is offline
 
Join Date: Jul 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 11-23-2009, 12:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);
Reply With Quote
  #3  
Old 11-23-2009, 03:08 PM
burn4cid burn4cid is offline
 
Join Date: Jul 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 11-23-2009, 03:22 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...)
Reply With Quote
  #5  
Old 11-23-2009, 04:08 PM
burn4cid burn4cid is offline
 
Join Date: Jul 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 11-23-2009, 04:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 11-23-2009, 08:06 PM
burn4cid burn4cid is offline
 
Join Date: Jul 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OMG you r right $vbulletin needs to be added global

ty
Reply With Quote
  #8  
Old 04-15-2010, 08:29 AM
Citizen Bleys Citizen Bleys is offline
 
Join Date: Feb 2003
Location: Moncton, NB
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 04-15-2010, 11:35 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 04-15-2010, 11:43 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Citizen Bleys View Post
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)
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 09:07 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.05600 seconds
  • Memory Usage 2,269KB
  • Queries Executed 11 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (8)bbcode_code
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • 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