Does anyone know how to add custom buttons to TinyMCE. I can't seem to find what i'm looking for.
Thanks
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.
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