Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: bbcode in comments buttons  (Read 5555 times)

0 Members and 1 Guest are viewing this topic.

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
bbcode in comments buttons
« on: December 21, 2006, 11:25:16 am »

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?
« Last Edit: December 22, 2006, 07:12:05 am by GauGau »
Logged

Nibbler

  • Guest
Re: bbcode in comments buttons
« Reply #1 on: December 21, 2006, 01:10:44 pm »

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

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: bbcode in comments buttons
« Reply #2 on: December 21, 2006, 07:07:11 pm »

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

Cheers
Nick
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: bbcode in comments buttons
« Reply #3 on: December 21, 2006, 10:57:27 pm »

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:
Code: [Select]
<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:

Code: [Select]
<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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: bbcode in comments buttons
« Reply #4 on: December 22, 2006, 07:11:53 am »

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

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: bbcode in comments buttons
« Reply #5 on: December 22, 2006, 07:15:24 am »

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.