![]() |
How do I Add {option} to built-in [code]
I have been modifying the "bbcode_code" template. How do I add an option to the built-in code tag?
Built in: [ CODE ] some random code [ /CODE ] With Option: [ CODE=javascript ]some random code[ /CODE ] Then I could print out the option to display the type of code, instead of just the word "Code" it would say "JavaScript Code". below is an example of the bbcode_code template and {option} should just print out the option. Code:
<div class="bbcode_container"> Dave |
I don't think you can do that without editing the file includes/class_bbcode.php.
Assuming you're willing to do that: If you search that file for [code] you find it in two places. In one place it's adding to the tag array. There you could add a second entry ($tag_list['option']['code']) that has the same values as the 'no_option' tag. The other place you'll find [code] is at the function handle_bbcode_code. There you need to add a second parameter for the option, then register that to the template. You'll also probably want to add a check in the template for the option value being null (which will happen with a code tga with no option). |
Thanks kh99, I am almost there, but there is some bug I can't figure out, I hope you can help?
using [ code ] without the option works perfectly. When I pass the option, it displays correctly, but if I try and edit the post, i see that the [ code ] tags have been removed and reformatted. Result when trying to edit post when I included the option: http://koshok.com/vb/code_01.png Below is my code. function: PHP Code:
PHP Code:
Code:
<div class="bbcode_container"> |
why can't the dev team just put all the built-in code in the BB Code Manager in the first place? I've been meaning to ask this question for years!
|
Quote:
Yeah, sorry - obviously I didn't actually try it. Anyway, more changes needed in includes/class_bbcode_alt.php. Around line 99, after the "make the "pre" tags use the correct handler" for loop (ETA ...add this under the existing foreach loop): Code:
if (isset($this->tag_list['option']['code'])) then in handle_preformatted_tag() around line 357, replace the return statement with: Code:
return '[' . $tag_name . (which I stole from another function). There's also another class in that file, vB_BbCodeParser_PlainText, which probably needs to be changed for when the post is represented as plain text. Quote:
|
That's true, indeed. However, there could be an include file (with hooks) for each bbcode that can be easily edited and make it easier for upgrades.
|
That would be nice.
|
if we suggest it now, maybe it'll get implemented in a few years.
|
heh heh...yeah, it's probably not on the top of the list. I was just thinking about it - I think the main problem is that the way it's written now, the callback functions for handling bbcodes have to be member functions of the bbcode parser class. But it would be easy enough to allow other callback functions, and then I think a lot more could be done in a plugin.
|
i cant even find a way to do it in my admincp project (https://vborg.vbsupport.ru/showthread.php?t=282849) without frontend code modification. I've been thinking about it long and hard too.
|
All times are GMT. The time now is 06:33 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|