The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How do you script BB Code?
Okay... lets say I want to make a bbcode... [VIDEO]536[/VIDEO]
I want to parse some PHP code on this code. How would I handle this? PHP Code:
|
#2
|
|||
|
|||
Okay... since no one knows how to script BB code... how about something different...
How would I make a script that examines a new post and preg_matches a thread and replaces it with content? So if someone made a post and it had: [VIDEO]536[/VIDEO]I would want it to preg_match it with: \[(VIDEO|video)](\d*)\[/(VIDEO|video)]Then of course, I would run some PHP code on the preg_match[2] returned as 536. Would this be possible? |
#3
|
|||
|
|||
Quote:
You'll require two plugins for this. I posted their source as xml just because it included everything. Just pay particular attention to the hook location and the basic functions I included. This one will take the text to be posted, and submit it to a function so can it can be run through a preg_replace or similar function. Code:
<plugin active="1" executionorder="5"> <title>Title Of Mod</title> <hookname>postbit_display_complete</hookname> <phpcode><![CDATA[global $vbulletin; $this->post['message'] = Function_Name($this->post['message']); ]]></phpcode> </plugin> Code:
<title>Plugin Title</title> <hookname>global_start</hookname> <phpcode><![CDATA[ function Function_Name($post) { global $vbulletin; //Preg_replace + other Functions return $post; } ]]></phpcode> |
#4
|
||||
|
||||
That is not adding another BB code. You can add a proper BB code (using PHP processing) by adding your tag to the processing array and setting the callback as the external callback function. Look at the bottom of class_bbcode.php.
|
#5
|
|||
|
|||
Huh? I'm confused... is there a guide somewhere?
All I want to do is have a BB Code, with a PHP function run on it. |
#6
|
||||
|
||||
All the information you need is in that post.
|
#7
|
|||
|
|||
Is there any way of doing this WITHOUT editing VB files? And I dont know what I am supposed to be looking at in class_bbcode.php.
|
#8
|
||||
|
||||
Yes, and that is what I'm telling you.
You will see how tags are defined. Define your own tag and callback. |
#9
|
|||
|
|||
Do you mind actually explaining what needs to be done? Because I still dont see what I'm supposed to be looking at.
*EDIT* ah... I think I get it now, you wanted me to see: ($hook = vBulletinHook::fetch_hook('bbcode_fetch_tags')) ? eval($hook) : false; I tried doing this... Code:
// [VIDEO] require_once(DIR . '/includes/functions_videodirectory.php'); $tag_list['no_option']['video'] = array( 'callback' => 'handle_external', 'external_callback' => 'handle_bbcode_video', 'strip_empty' => true ); Fatal error: Call to undefined method vB_BbCodeParser::handle_bbcode_video() in /home/eightway/public_html/includes/class_bbcode.php on line 1143 How do I get it to call handle_bbcode_video in functions_videodirectory.php? --------------- Added [DATE]1231967882[/DATE] at [TIME]1231967882[/TIME] --------------- Well I figured to just use the function in the plugin itself, instead of calling a file... But I'm having trouble passing the parameter data... Code:
// [VIDEO] $tag_list['no_option']['video'] = array( 'callback' => 'handle_external', 'external_callback' => 'handle_bbcode_video', 'strip_empty' => true ); function handle_bbcode_video($videoid) { global $vbulletin; if (!$videoinfo = $vbulletin->db->query_first(" SELECT video.* FROM " . TABLE_PREFIX . "video AS video WHERE video.videoid = '" . $videoid . "'") ) { return 'This video does not exist'; } require_once(DIR . '/includes/class_videosharingservice.php'); require_once(DIR . '/includes/videoserviceapi/class_' . strtolower($videoinfo['videoservice']) . '.php'); $classname = 'vB_VideoSharingService_' . $videoinfo['videoservice']; $obj = new $classname($vbulletin); $embedhtml = $obj->fetch_embedcode($videoinfo['videoidservice']); return $embedhtml; } --------------- Added [DATE]1231974120[/DATE] at [TIME]1231974120[/TIME] --------------- Is there a guide or something that explains what all the array options in $tag_list do? |
#10
|
||||
|
||||
You've done a lot of work - and it shows, because you're nearly there. I'm going to give you the rest of it, because unlike a lot of people, you've actually tried doing it yourself.
Hook: bbcode_fetch_tags PHP Code:
PHP Code:
PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|