vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   I need help parsing BBCode (https://vborg.vbsupport.ru/showthread.php?t=255388)

just.b.jealous 12-17-2010 04:38 AM

I need help parsing BBCode
 
I've made a custom page by making a new template called "TEST" then using the following PHP code:
PHP Code:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE & ~8192);  
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''test'); // change this depending on this files name
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array('TEST',);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
eval('print_output("' fetch_template('TEST') . '");');
?>

Saved it as "test.php",.. then view it to see whatever I put into the "TEST" template. Right now I have it pulling the most recent threads, posters name, date posted, and the contents of the post itself. Everything is working fine except the BBCode isn't being formatted after being pulled from the DB, can anybody help me figure this out, ??

Digital Jedi 12-17-2010 06:43 PM

Did you ever make any of the edits PirdOPrey5 showed you in the thread where you initially asked this question?

just.b.jealous 12-19-2010 09:58 PM

I have now, but I'm still stuck.....


Quote:

Originally Posted by BirdOPrey5 (Post 2135209)
You need to initialize and use the BB Code parser...
In the php file near the top add the lines:

PHP Code:

   require_once(DIR '/includes/class_bbcode.php');
   
$bbcode_parser =& new vB_BbCodeParser($GLOBALS['vbulletin'], fetch_tag_list(),true); 

Then you can use this line (change the $rawthread and $parsedthread variables to your needs) to get the parsed output (BB Code converted to HTML)

PHP Code:

 $parsedthread=  $bbcode_parser->parse($rawthread ,'nonforum'true); 

The "true" on the end is to parse smilies too... if you don't want smilies make it "false".

awesome, thanks for helping me out,.. I'm a little stuck at the moment though,.. could you take a look at my test.php page for me- it's still not parsing BBCode,..

PHP Code:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE & ~8192);  
require_once(
DIR '/includes/class_bbcode.php'); 
$bbcode_parser =& new vB_BbCodeParser($GLOBALS['vbulletin'], fetch_tag_list(),true);
$parsedthread=  $bbcode_parser->parse($rawthread ,'nonforum'true);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''test'); // change this depending on this files name
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array('TEST',);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
eval('print_output("' fetch_template('TEST') . '");');
?>

Using:
PHP Code:

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

Gives me this error:
Quote:

Warning: require_once(DIR/includes/class_bbcode.php) [function.require-once]: failed to open stream: No such file or directory in /forum/test.php on line 4
Fatal error: require_once() [function.require]: Failed opening required 'DIR/includes/class_bbcode.php' (include_path='.:/usr/local/php5/lib/php') in /forum/test.php on line 4
Using:
PHP Code:

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

Gives me this error:
Quote:

Fatal error: Class 'vBulletinHook' not found in /forum/includes/class_bbcode.php on line 2463



I'm also a little confused on what to do with:
Then you can use this line (change the $rawthread and $parsedthread variables to your needs) to get the parsed output (BB Code converted to HTML)

kh99 12-19-2010 10:11 PM

I think that stuff you added (starting with the require_once class_bbcode.php) needs to go below the require_once('./global.php');


All times are GMT. The time now is 01:36 AM.

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.02849 seconds
  • Memory Usage 1,746KB
  • 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
  • (6)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete