TinyMCE Custom Buttons

TinyMCE Custom Buttons

by David Peachey -
Number of replies: 8

Does anyone know how to add custom buttons to TinyMCE. I can't seem to find what i'm looking for.

Thanks

Average of ratings: -
In reply to David Peachey

Re: TinyMCE Custom Buttons

by Mauno Korpelainen -
In reply to Mauno Korpelainen

Re: TinyMCE Custom Buttons

by David Peachey -
Something like this: http://tinymce.moxiecode.com/examples/example_20.php. I really just don't know what file to edit.
In reply to David Peachey

Re: TinyMCE Custom Buttons

by Mauno Korpelainen -

You need to find the init code first - if you are using Glen's TinyMCE integration check theme/tinymce_integration/footer.html

That example gives you source and from that example you can take the yellow parts

<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
theme_advanced_buttons1 : "mybutton,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
plugins : 'inlinepopups',
setup : function(ed) {
// Add a custom button
ed.addButton('mybutton', {
title : 'My button',
image : 'img/example.gif',
onclick : function() {
// Add you own code to execute something on click
ed.selection.setContent('<STRONG>Hello world!</STRONG>');
}
});
}
});
</script>

Note that the last row in init code does not have  ","  at the end - all other rows in init code have "," at the end.

In reply to Mauno Korpelainen

Re: TinyMCE Custom Buttons

by David Peachey -
I'm a bit confused, that file you're talking about doesn't exist.
In reply to David Peachey

Re: TinyMCE Custom Buttons

by Mauno Korpelainen -
You did not mention which TinyMCE integration you have so I supposed that you are using http://moodle.org/mod/data/view.php?d=13&rid=1119 by Glen Davis.

Can you first check the version of your moodle and which tinymce integration is it? You need to find the init code for tinymce first to be able to change it...
In reply to Mauno Korpelainen

Re: TinyMCE Custom Buttons

by David Peachey -
Right sorry. I'm using Moodle 1.9, so whichever version comes with that version.
In reply to David Peachey

Re: TinyMCE Custom Buttons

by Mauno Korpelainen -

Now I'm a bit confused - default editor of moodle 1.9 is HTMLArea, not TinyMCE.

All version of moodle before 2.0 have an old folder lib/editor/tinymce - Janne Mikkonen added TinyMCE 2 several years ago and some sites may still use integration through weblib.php (or Janne's special cases)

Also Martín Langhoff made a clean port integration for moodle 1.9 some months ago http://moodle.org/mod/forum/discuss.php?d=107550 , I made some theme based test intgrations about year ago and there may be some other versions and many people use Glen's version but you should first know which editor integration it is. All recent integration are using TinyMCE 3.

Attached toolbar is from HTMLArea

Attachment toolbar.gif
In reply to Mauno Korpelainen

Re: TinyMCE Custom Buttons

by David Peachey -
Oh ok, that clears up things up a bit. I saw there was a tinymce folder so I assumed that's what it was. That's what it looks like.

Sorry for the confusion.