The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
![]()
Plugin based CKeditor friendly BBcode in vB4.1.8+ - howto
I've put all the Ausphotography (AP) custom BBcodes into a plugin. Here is a skeleton example (with detailed comments) of how to do it. Skills needed: Intermediate PHP and vBulletin admin. Tutorial In the example the BBcode is 'w' which allows a warning to be posted in a thread. Make sure you BBcode does not conflict with the standard BBcodes or any other product BBcodes you have on your system. You can add multiple BBcodes using one plugin, just code a call back function for each and set the tags for each BBcode following the example. The syntax is (no option and option to change the Warning text): Code:
[w]Warning Message[/w] [w="Notice"]Notice Message[/w] If you want an icon for your BBcode create and copy a small icon (say) APwarning.png (18x18) to your ./images/editor directory, the record insert will need the icon path in the buttonimage field. Attachment 134799 Product xml file Write a small product xml file that looks like the example below. Name it 'product_my_bbcodes.xml' You will need to write a call back function and set the tag list entries. Install the product via AdminCP. You will need to adjust the insert records. The options are a bit field based on: - strip_empty - 1 - stop_parse - 2 - disable_smilies - 4 - disable_wordwrap - 8 - disable_urlconversion - 16 Call back function Each BBcode will require a call back function as shown in the example and the tag_list definitions. The return function is what is put in the parsed post. You can implement database accesses in the BBcode processor (you need global $vbulletin; enabled per normal. Note this code is CKeditor friendly in that it tells CKeditor to ignore your BBcode in WYSIWYG mode. Tag list The tag list defines which options are active on the BBcode tag and should match the options of the insert record. Enjoy! Kym __________________________________________________ Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <product productid="my_bbcodes" active="1"> <title>AP BBcode processor</title> <description><![CDATA[Provides BBcodes eg. w (WARNING)]]></description> <version>4.1.8</version> <url><![CDATA[http://www.ausphotography.net.au/forum/index.php]]></url> <versioncheckurl></versioncheckurl> <dependencies> <dependency dependencytype="vbulletin" minversion="4.1.8" maxversion="" /> </dependencies> <codes> <code> <installcode><![CDATA[ // Put '' in the buttonimage field if you are NOT using an icon in the editor // Eg. 'images/editor/APwarning.png' becomes '' if you dont want an icon. // twoparams needs to be 1 if your BBcode has options, or 0 if it does not. $db->query_write(" INSERT INTO " . TABLE_PREFIX . "bbcode (bbcodetag, bbcodereplacement, bbcodeexample, bbcodeexplanation, twoparams, title, buttonimage, options) VALUES ('w', 'Please refresh this page.', '[w=\"Warn:\"]Demo Text[/w]', 'Warning BB code.', 1, 'Warning', 'images/editor/APwarning.png', 1) ON DUPLICATE KEY UPDATE bbcodereplacement = VALUES(bbcodereplacement), bbcodeexample = VALUES(bbcodeexample), bbcodeexplanation = VALUES(bbcodeexplanation), twoparams = VALUES(twoparams), title = VALUES(title), buttonimage = VALUES(buttonimage), options = VALUES(options); "); build_bbcode_cache(); // force the BBcode cache to update ]]></installcode> <uninstallcode><![CDATA[ $db->query_write(" DELETE FROM " . TABLE_PREFIX . "bbcode WHERE bbcodetag = 'w' LIMIT 1; "); build_bbcode_cache(); // force the BBcode cache to update ]]></uninstallcode> </code> </codes> <templates> </templates> <stylevardfns> </stylevardfns> <stylevars> </stylevars> <plugins> <plugin active="1" executionorder="5"> <title>AP BBcode processing</title> <hookname>bbcode_create</hookname> <phpcode><![CDATA[ // **************************** // W Warning call back function if(!function_exists('handle_w_callback')) { function handle_w_callback(&$parsed, $valuex, $option='') { // global $vbulletin; // needed if you are going to database accesses in the BBcode processing if (!empty($option)) { $apwtxt = $option; } else { $apwtxt = 'Warning'; // Default option } return '<blockquote class="blockrow postcontent restore preview postcontainer forumcontent"> <div class="contentnote" style="border: 1px solid;padding:5px;"><span style="color:DarkOrange;"><b>'.$apwtxt.': </b></span>'.$valuex.'</div> </blockquote>'; } // end handle_w_callback. } // end of handler $this->tag_list['no_option']['w'] = array( // tag the call back when option is not present 'callback' => 'handle_external', 'external_callback' => 'handle_w_callback', 'strip_empty' => true, // remove empty tags 'stop_parse' => false, // allow the tag to contain other BBcodes 'wysiwyg_no_parse' => 1, // tell CKeditor to ignore this tag 'disable_smilies' => false, // allow smilies 'disable_wordwrap' => false // allow word wrapping ); $this->tag_list['option']['w'] = array( // tag the call back when option present 'callback' => 'handle_external', 'external_callback' => 'handle_w_callback', 'strip_empty' => true, // remove empty tags 'stop_parse' => false, // allow the tag to contain other BBcodes 'wysiwyg_no_parse' => 1, // tell CKeditor to ignore this tag 'disable_smilies' => false, // allow smilies 'disable_wordwrap' => false // allow word wrapping ); ]]></phpcode> </plugin> </plugins> <phrases> </phrases> <options> </options> <helptopics> </helptopics> <cronentries> </cronentries> <faqentries> </faqentries> </product> |
Благодарность от: | ||
miiax6 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|