The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
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"> <div class="bbcode_description">{option} {vb:rawphrase code}:</div> <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']">style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre> </div> Dave |
#2
|
|||
|
|||
![]()
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). |
#3
|
|||
|
|||
![]()
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: ![]() Below is my code. function: PHP Code:
PHP Code:
Code:
<div class="bbcode_container"> <div class="bbcode_description">{vb:raw option}:</div> <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']">style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre> </div> |
#4
|
||||
|
||||
![]()
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!
|
#5
|
|||
|
|||
![]() 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'])) { $this->tag_list['option']['code']['callback'] = 'handle_preformatted_tag'; unset($this->tag_list['option']['code']['html'], $this->tag_list['option']['code']['strip_space_after']); } then in handle_preformatted_tag() around line 357, replace the return statement with: Code:
return '[' . $tag_name . ($this->current_tag['option'] !== false ? ('=' . $this->current_tag['delimiter'] . $this->current_tag['option'] . $this->current_tag['delimiter']) : '' ) . ']' . $this->emulate_pre_tag($code) . "[/$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. I don't know, but the handling of some of those codes is a lot more complicated than just a replacement, so it would be difficult. |
#6
|
||||
|
||||
![]()
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.
|
#7
|
|||
|
|||
![]()
That would be nice.
|
#8
|
||||
|
||||
![]()
if we suggest it now, maybe it'll get implemented in a few years.
|
#9
|
|||
|
|||
![]()
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.
|
#10
|
||||
|
||||
![]()
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.
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|