The WYSIWYG module does a great job of centralizing and abstracting the use of various graphical editors in Drupal. Its relative newness means it is poorly and confusingly documented in some respects. I recently had to add the headings plugin for TinyMCE and ran into a lot of confusing information about how to make that happen.
My solution, and the recommended approach, is to use the hook_wywiwyg_plugin() API in a custom module to make the plugin available to WYSIWYG. There were a lot of contradictory examples of the code out there. This is what wound up working for me. Note that I installed the heading plugin in the tinymce plugins directory under sites/all/libraries.
/** * Implementation of hook_wywiwyg_plugin(). */ function FOOBAR_wysiwyg_plugin($editor, $version=0) { $plugins = array(); switch ($editor) { case 'tinymce': if ($version > 3) { $plugins['heading'] = array( 'type' => 'external', 'title' => t('Headings'), 'description' => t('Provides H1-H6 buttons for tinyMCE'), 'path' => wysiwyg_get_path($editor) . '/jscripts/tiny_mce/plugins/heading/editor_plugin.js', 'buttons' => array( 'h1' => t('H1'), 'h2' => t('H2'), 'h3' => t('H3'), 'h4' => t('H4'), 'h5' => t('H5'), 'h6' => t('H6'), ), 'url' => 'http://sourceforge.net/tracker/index.php?func=detail&aid=1467705&group_id=103281&atid=738747', 'load' => TRUE, ); } break; } return $plugins; }
- TinyMCE
- Computing
- Application software
- editor
- API
- http://sourceforge.net/tracker/index.php?func=detail&aid=1467705&
- $editor
- php



Comments
Thank you for this, I have
Thank you for this, I have been having lot of issues with tinymce and header buttons. As soon as I turned the inbuilt heading dropdown list it seems to bitch an strip lot of other tags from the content (footnote etc)
HUGZ!!
Thank you SO much for this! I was most of the way to this implementation, but decided to give a more thorough look at the google results, and so found this. TOTALLY saved me hours!!
Almost works
This helped a lot. I haven't created Drupal modules before but I found another guide for that which led me to the following steps.
Create the folder with the new module name (in my case tinymce_heading), create tinymce_heading.info, create tinymce_heading.module, and fill it with your code above. Replace FOOBAR with my module name (resulting in tinymce_heading_wysiwyg_plugin).
I enabled the module, went into my input format settings and added the newly available h2 and h3 buttons (the only ones I needed to use), and they showed up on the input field next time I checked.
Only problem is, they don't do anything. You can click 'em all you want, nothing happens.
I do have editor_plugin.js in /library/jscripts/tiny_mce/plugins/heading/
Think it's just a path issue?
Hey Adam,
Hey Adam,
Did you ever figure out this issue? I am stuck at that same spot currently. The button will show, but will not actually do anything.
Thanks
even it doesn't work for me.
even it doesn't work for me.
My error console shows this error
Error: Z is undefined
Source File: http://example.com/sites/all/libraries/tinymce/jscripts/tiny_mce/tiny_mc...
Line: 1
Thanks for that
OMG, TinyMCE has been driving me absolutely crazy, but this fixed my issue. Thank you.
Add new comment