View Full Version : php BB code
Barrikin
10-19-2004, 11:13 PM
I want to be able to use [php=thefilename.php]
So it puts a lenged for the table. Kinda like a quote tag.
What would the best way to go about this?
I think all the bb code functions should be handle within the admincp.
Xenon
10-20-2004, 05:35 PM
well some functions cannot be handled just within the acp, as the code highlighting is not doable with plain html, but needs some php.
but actually it's not hard to achieve something similar,
look into include/functions_bbcodeparse.php
you can see there how the quote code is handled (take a closer look at the $username parameter) and just add the same things to the php tag part of the code :)
Barrikin
10-21-2004, 12:22 AM
I've look and found this
// [QUOTE]
$bbcodes['custom']['find']['[quote]'] = '#\[quote\](<br>|<br />|\r\n|\n|\r)??(.*)(<br>|<br />|\r\n|\n|\r)??\[/quote\]#esiU';
$bbcodes['custom']['replace']['[quote]'] = "handle_bbcode_quote('\\2')";
$bbcodes['custom']['recurse']['quote'][0] = array('handler' => 'handle_bbcode_quote');
// [QUOTE=XXX]
$bbcodes['custom']['find']['[quote='] = '#\[quote=("|"|\'|)(.*)\\1\](<br>|<br />|\r\n|\n|\r)??(.*)(<br>|<br />|\r\n|\n|\r)??\[/quote\]#esiU';
$bbcodes['custom']['replace']['[quote='] = "handle_bbcode_quote('\\4', '\\2')";
$bbcodes['custom']['recurse']['quote'][1] = array('handler' => 'handle_bbcode_quote');
// [PHP] - this is the first custom tag because it does weird things to HTML
$bbcodes['custom']['find']['[php]'] = '#\[php\](<br>|<br />|\r\n|\n|\r)??(.*)(<br>|<br />|\r\n|\n|\r)??\[/php\]#esiU';
$bbcodes['custom']['replace']['[php]'] = "handle_bbcode_php('\\2')";
$bbcodes['custom']['recurse']['php'][0] = array('handler' => 'handle_bbcode_php');
So how would i go about this?
Barrikin
10-21-2004, 12:25 AM
I guess i'd use something like this?
// [QUOTE=XXX]
$bbcodes['custom']['find']['[php='] = '#\[php=("|"|\'|)(.*)\\1\](<br>|<br />|\r\n|\n|\r)??(.*)(<br>|<br />|\r\n|\n|\r)??\[/php\]#esiU';
$bbcodes['custom']['replace']['[php='] = "handle_bbcode_php('\\4', '\\2')";
$bbcodes['custom']['recurse']['php'][1] = array('handler' => 'handle_bbcode_php');
Not sure if i'm even close. lol
Xenon
10-21-2004, 10:43 AM
exactly, you are very closed.
add that code block under the old php code.
but your not done yet, you have to change the handle_bbcode_php function to accept an optional parameter, and then just put the optional parameter into the bbcode_php template.
try to find out how to do it.
If you won*'t find it, i can tell you when i'm back from university :)
Barrikin
10-22-2004, 10:21 AM
Allright, i got it working.. Thanks alot :)
Xenon
10-22-2004, 04:06 PM
you're welcome :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.