Add A Button To The Editor (vb3)
by
18 Jan 2004
This will help you add an extra button to vb3's editor toolbar. The button calls a function that you define in vbulletin_global.js that can do anything you want. Originally posted here. Spoiler (click to open)
Quote by zozex
Open ./includes/functions_editor.php and find this:
PHP Code:
global $datastore, $bbcodecache;
PHP Code:
global $datastore, $bbcodecache, $stylevar;
PHP Code:
foreach ($bbcodecache AS $bbcode)
Code:
if ($toolbartype == 2){ $extrabuttons .= '<td><div class="imagebutton" id="cmd_realone"><img src="' . $stylevar[imgdir_editor] . '/realone.gif" alt="Real One" width="21" height="20" /></div></td>'; }else{ $extrabuttons .= '<td><div class="imagebutton"><a href="#" onclick="return realone()"><img src="' . $stylevar[imgdir_editor] . '/realone.gif" alt="Real One" title="Real One" width="21" height="20" border="0" /></a></div></td>'; } Now, open clientscript/vbulletin_wysiwyg.js and find this: Code:
htmlbox.execCommand(formatcommand, showinterface, extraparameters); set_context(formatcommand); Code:
if(formatcommand == 'realone') { realone(); }else{ // this was original but outside IF htmlbox.execCommand(formatcommand, showinterface, extraparameters); set_context(formatcommand); } Close
Open ./includes/functions_editor.php and find this: PHP Code:
global $datastore, $bbcodecache;
PHP Code:
global $datastore, $bbcodecache, $stylevar;
PHP Code:
foreach ($bbcodecache AS $bbcode)
Code:
if ($toolbartype == 2){ $extrabuttons .= '<td><div class="imagebutton" id="cmd_xxxx"><img src="' . $stylevar[imgdir_editor] . '/xxxx.gif" alt="<Alt Text>" width="21" height="20" /></div></td>'; }else{ $extrabuttons .= '<td><div class="imagebutton"><a href="#" onclick="return xxxx()"><img src="' . $stylevar[imgdir_editor] . '/xxxx.gif" alt="<Alt Text>" title="<Alt Text>" width="21" height="20" border="0" /></a></div></td>'; } Now, open clientscript/vbulletin_wysiwyg.js and find this: Code:
htmlbox.execCommand(formatcommand, showinterface, extraparameters); set_context(formatcommand); Code:
if(formatcommand == 'xxxx') { xxxx(); }else{ // this was original but outside IF htmlbox.execCommand(formatcommand, showinterface, extraparameters); set_context(formatcommand); } And open clientscript/vbulletin_global.js and add a function called whatever you changed xxxx to. It can do whatever you want it to do and you'll be set. If you want to add it to the showthread quick reply... open showthread.php and find: PHP Code:
eval('$quickreply = "' . fetch_template('showthread_quickreply') . '";');
PHP Code:
$extrabuttons = construct_editor_extra_buttons($WYSIWYG);
HTML Code:
<td><div class="imagebutton" id="cmd_wrap0_quote"><img src="$stylevar[imgdir_editor]/quote.gif" alt="$vbphrase[wrap_quote_tags]" width="21" height="20" /></div></td> HTML Code:
<if condition="$extrabuttons"><td>$extrabuttons</td></if> HTML Code:
<td><div class="imagebutton"><a href="#" onclick="return vbcode('QUOTE', '')"><img src="$stylevar[imgdir_editor]/quote.gif" alt="$vbphrase[wrap_quote_tags]" title="$vbphrase[wrap_quote_tags]" width="21" height="21" border="0" /></a></div></td> HTML Code:
<if condition="$extrabuttons"><td>$extrabuttons</td></if> |