vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Parse bbcode in any php file (https://vborg.vbsupport.ru/showthread.php?t=61736)

Boofo 02-19-2004 04:32 PM

Parse bbcode in any php file
 
What would I need to put at the top of a PHP file (that calls my rules template) to make it so any bbcode in the template will be parsed, like smilie code?

Xenon 02-19-2004 04:39 PM

PHP Code:

require('./includes/functions_bbcodeparse.php'); 

then you can call parse_bbcode2() to parse any texts

Boofo 02-19-2004 04:41 PM

I did the first part but basically all the php file has in it is the

eval('print_output("' . fetch_template('rules') . '");');

which calls the template. How would I parse that?

Andreas 02-19-2004 04:41 PM

PHP Code:

require_once('./global.php');
require_once(
'./includes/functions_bbcodeparse.php');

$vboptions['allowbbcode'] = true;
$vboptions['allowsmilies'] = true;
// If you also want tp parse HTML:
// $vboptions['allowhtml'] = true;
// If you also want to parse IMG-Code
// $vboptions['allowbbimagecode'] = true;
$myrules_parsed parse_bbcode($myrules'nonforum'true); 


Boofo 02-19-2004 04:47 PM

Here's what I have for the php file that calles the rules template. That didn't work, KirbyDE, for some reason. ;)

PHP Code:

<?php
error_reporting
(E_ALL & ~E_NOTICE);
 
// pre-cache templates used by all actions
$globaltemplates = array('header,navbar,rules');
define('OVERWRITE_STYLEID'1);
 
// ## Grabs global.php ##
require("./global.php");
require(
'./includes/functions_bbcodeparse.php');
 
// ## yeap what it says ##
define('NO_REGISTER_GLOBALS'1);
 
// ## defines this script as chat if you use phpinclude_start for this page at all ##
define('THIS_SCRIPT''rules');
 
$vboptions['allowbbcode'] = true
$vboptions['allowsmilies'] = true
// If you also want tp parse HTML: 
// $vboptions['allowhtml'] = true; 
// If you also want to parse IMG-Code 
// $vboptions['allowbbimagecode'] = true; 
$rules_parsed parse_bbcode($rules'nonforum'true);
 
eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('rules') . '");');
?>


Xenon 02-19-2004 04:50 PM

you may use this:

PHP Code:

$rules fetch_template('rules');
$rules parse_bbcode2($rules1111);
eval(
'print_output("' addslashes($rules) . '");'); 


Boofo 02-19-2004 04:54 PM

That almost worked. I got a IE runtime error, some invalid character. It wouldn't load the editor for some reason.

Xenon 02-19-2004 05:00 PM

hmm, maybe it parses some bbcode where you don't want them to be parsed?

but i don't think that's avoidable.

normally you shouldn't parse bb code in templates at all ;)

Boofo 02-19-2004 05:02 PM

Can I just parse smilies? That is all I really need to be parsed in this template.

Andreas 02-19-2004 05:07 PM

Erm ... why don't you just put in the appropriate <IMG>-Tags?
Would be easier IMHO.

Boofo 02-19-2004 05:12 PM

I never thought of that. Thank you. ;)

But for future reference, would there be any way to do something like this? They do it in the newreply for pagetext but I'm not sure how to set something like that up for something like this.

Xenon 02-19-2004 07:34 PM

well you can parse just the smilies with the pars_bbcode2 function, the several 1's stand for parsing options, (HTML, bbcode, smilies, imgs...) just set it the right way :)

and always allow html parsing or your templates would result in a very funny thing ^^

Boofo 02-19-2004 08:36 PM

I tried that but all I got what the html code for the file. It looked really strange. I just went ahead and did a path to the image file. It was alot easier than trying to figure out what I did wrong. ;)

liquidx 06-26-2004 11:10 PM

I'm trying to parse BBCode in a PHP script, but it gives errors when its not in the same directory as the forums..

I chdir("forums/"); before including global.php and it eliminates the file not found errors from the includes, but it still doesn't work.. I get:
Fatal error: Call to a member function on a non-object in /www/forums/includes/functions.php on line 899

When I use the same code from within the forums directory, it works just fine..
Why?


All times are GMT. The time now is 02:07 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.01036 seconds
  • Memory Usage 1,751KB
  • 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
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)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