Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Has anybody added their own custom tag buttons to the advanced or basic editor?

Quote Reply
Has anybody added their own custom tag buttons to the advanced or basic editor?
I'm wondering if anybody has added their own custom tag buttons to the advanced or basic editor.

Where you see in the advanced editor B I [/i]U [/u]"" [/b] etc I'd like to add a new one so that it places the basic tag on the page for the user and all they need to do then is fill in the text between the tags.

I'm thinking on the advanced editor maybe I can simply swamp out what is placed for the [/b] tag since that would be the most common recognizable visual cue for the tag that we use on our forums, but if someone has added new ones to either advanced or basic editors and wishes to share how you did it, I'd sure appreciate it.

Thanks,

Last edited by:

Westin: May 14, 2009, 6:43 AM
Quote Reply
Re: [Westin] Has anybody added their own custom tag buttons to the advanced or basic editor? In reply to
Should be quite simple. Not sure of the template (probably include_post_common_write.html and include_post_html_common_write.html).

Add this to those templateS:

Code:
function addTagCustom(tag) {
if (document.post.post_message.createTextRange && document.post.post_message.cursorPosition) {
var cursorPosition = document.post.post_message.cursorPosition;
cursorPosition.text = cursorPosition.text.charAt(cursorPosition.text.length - 1) == ' ' ? '[' + tag + '] ' : "[" + tag + "]";
}
else {
document.post.post_message.value += "[" + tag + "]";
}
document.post.post_message.focus();
return;
}

Then add this:

Code:
<input type="button" class="button" name="markup_tag_test" tabindex=30 value="test" onClick="javascript: addTagCustom(this.value);">

...below alongside:

Code:
<input type="button" class="button" name="markup_tag_url" tabindex=30 value="url" onClick="javascript: addTag(this.value); this.value = (this.value == 'url' ? '/url' : 'url');">

I tested this quickly, and seems to work fine :)

The example one, would add [test] into the post_message field.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Has anybody added their own custom tag buttons to the advanced or basic editor? In reply to
Can't seem to get this to work at all.

Basically I can't get the button for the test to show up at all.

Here's what I've got, Im including some lines before and after your coding as a reference point of where I placed it in these specific files:

Template: /include_message_common_write.html
Code:
Every page involving writing a message uses this common page
as an include for the actualy display.

--%>

<!-- NEW CODE -->
function addTagCustom(tag) {
if (document.post.post_message.createTextRange && document.post.post_message.cursorPosition) {
var cursorPosition = document.post.post_message.cursorPosition;
cursorPosition.text = cursorPosition.text.charAt(cursorPosition.text.length - 1) == ' ' ? '[' + tag + '] ' : "[" + tag + "]";
}
else {
document.post.post_message.value += "[" + tag + "]";
}
document.post.post_message.focus();
return;
}
<!-- END NEW CODE -->

<script language="Javascript">
<!--
function addTag(tag) {
if (document.message.msg_body.createTextRange && document.message.msg_body.cursorPosition) {


Template:
/include_message_common_write.html
Code:
<input type="button" class="button" name="markup_tag_email" tabindex=30 value="email" onClick="javascript: addTag(this.value); this.value = (this.value == 'email' ? '/email' : 'email');">
<input type="button" class="button" name="markup_tag_url" tabindex=30 value="url" onClick="javascript: addTag(this.value); this.value = (this.value == 'url' ? '/url' : 'url');">
<input type="button" class="button" name="markup_tag_url" tabindex=30 value="url" onClick="javascript: addTag(this.value); this.value = (this.value == 'url' ? '/url' : 'url');">
<!-- NEW CODE -->
<input type="button" class="button" name="markup_tag_test" tabindex=30 value="test" onClick="javascript: addTagCustom(this.value);">
<!-- END NEW CODE -->


Template:
/include_message_html_common_write.html

Code:
Every page involving writing a message uses this common page
as an include for the actualy display.

--%>

<!-- NEW CODE -->
function addTagCustom(tag) {
if (document.post.post_message.createTextRange && document.post.post_message.cursorPosition) {
var cursorPosition = document.post.post_message.cursorPosition;
cursorPosition.text = cursorPosition.text.charAt(cursorPosition.text.length - 1) == ' ' ? '[' + tag + '] ' : "[" + tag + "]";
}
else {
document.post.post_message.value += "[" + tag + "]";
}
document.post.post_message.focus();
return;
}
<!-- END NEW CODE -->
<%if ie_version >= 6%><object id="dlg" classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></object><%endif%>

I see nowhere in
/include_message_html_common_write.html to put the code:
Code:
<input type="button" class="button" name="markup_tag_test" tabindex=30 value="[c cardname][/c]" onClick="javascript: addTagCustom(this.value);">

I think there's got to be something added to: /local/editor_iframe.html
Quote Reply
Re: [Andy] Has anybody added their own custom tag buttons to the advanced or basic editor? In reply to
Woops my mistake I applied it to the wrong files. Going to try again.
Quote Reply
Re: [Westin] Has anybody added their own custom tag buttons to the advanced or basic editor? In reply to
Okay, got it somewhat working now.

It's a bit clunky unfortunately because, all the other options for the basic editor such as email and url tags don't work the same as the markup tags.

Perhaps if I could get it to work more like this.

User presses the button for the first time and it outputs (where (space) below is one blank space)
[c (space)

On the second press it adds
][/c]

In this way they can hit the button, it outputs to the message box: "[c " then they can add to it by typing in their user_input like "[c user_input" They hit the button again and it adds "][/c]" All together now, [c user_input][/c]

But I still have to ask myself. How many people actually use those kinds of buttons (like the b, i, etc), I mean really, if Im typing something with my hands on the keyboard, Im just going to type bold instead of having to press the b button, then type, then press the b button again. It's clunky to have to hit the buttons for that.

If it could do this:

User Input

The user highlights "User Input" and presses the necessary button, and it outputs to the screen [tag]User Input[/tag]

That would be useful. I guess Gossamer Forums just isn't up to par to do anything elaborate like I need to do with the conversion of the tag. Darn it.

Last edited by:

Westin: May 17, 2009, 10:29 PM