bbcode in comments buttons bbcode in comments buttons
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

bbcode in comments buttons

Started by nickfzx, December 21, 2006, 11:25:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nickfzx

I worked out the other day that I can put bbcode into comments (links and the like)

It would be great if there were some easy shortcut buttons like there are in this simple machines forum to make inserting bbcode really easy.

Does this already exhist...how hard would it be to make?

Nibbler

Not too hard, the javascript used for smf can be adapted for use inside Coppermine.

nickfzx

cool, ill look into that and post my results here if I figure it out.

Cheers
Nick

nickfzx

ok so ive figured this out

seems to work fine except does not give easybb options when editing a comment (because it tries to put it in the post form not the edit form so I just left the option out)

to see it in action you will have to goto my site and open an account as guests can't comment.

this is how to do it.

Open your template.html file and stick this javascript in the header:
<script type="text/javascript">
function insert_text(open, close){
msgfield = (document.all) ? document.all.msg_body : document.forms['post']['msg_body'];
// IE support
if (document.selection && document.selection.createRange)
{
msgfield.focus();
sel = document.selection.createRange();
sel.text = open + sel.text + close;
msgfield.focus();
}

// Moz support
else if (msgfield.selectionStart || msgfield.selectionStart == '0')
{
var startPos = msgfield.selectionStart;
var endPos = msgfield.selectionEnd;

msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
msgfield.focus();
}

// Fallback support for other browsers
else
{
msgfield.value += open + close;
msgfield.focus();
}

return;
}</script>


Then open themes.inc.php and search for <!-- END input_box_smilies --> (must have smilies enabled otherwise use the without smilies input box)

add this code just before that:

<div style="padding-top: 4px">
<input type="button" value=" B " name="B" onclick="insert_text('[b]','[/b]')" />
<input type="button" value=" I " name="I" onclick="insert_text('[i]','[/i]')" />
<input type="button" value="http://" name="Url" onclick="insert_text('[url]','[/url]')" />
<input type="button" value="Img" name="Img" onclick="insert_text('[img]','[/img]')" />
</div>


Hope this is clear enough...give me a shout if you need help with this.

Cheers

Nick

Joachim Müller

You mustn't edit include/themes.inc.php, under no circumstances. You're suppossed to edit themes/yourtheme/theme.php instead.

nickfzx

oh sorry I diddn't know this :-X...but I see the logic there...things could get messy if everyone was editing the include files.

anyone using little mod do what gaugau says and stick the code in theme.php.