When looking at the documentation on TinyMCE's site, they always mention editing the tinyMCE.init function. How can I do that properly with the WYSIWYG module?

Comments

twod’s picture

Status: Active » Fixed

Wysiwyg creates a settings object in PHP which is then converted to JavaScript and passed directly to the new editor instance when it's created.

You can modify the settings object just after it has been created in PHP by implementing hook_wysiwyg_editor_settings_alter() in a Drupal module. Documentation is in wysiwyg.api.php, #964978: Document hook_wysiwyg_editor_settings_alter() and there are more examples to be found in the issue queue by searching for that hook name.

If the TinyMCE documentation tells you to add a plugin name to the list of plugins to be loaded, and/or a button name to a toolbar, I instead recommend to implement hook_wysiwyg_plugins() (also documented in wysiwyg.api.php). That hook lets Wysiwyg know you've placed a plugin somehere (outside the TinyMCE folder is recommended to make upgrades easier), where it is and what it's called, which buttons it provides and some other "meta data". Implementing that hook makes the plugin's button(s) show up under admin/settings/wysiwyg -> "Buttons and plugins" and it makes the integration re-usable for other sites and people. Wysiwyg will also know it only needs to load the plugin if one or more of it's buttons have been enabled, unless it's a pure "extension" without buttons - in which case the plugin is loaded whenever its checkbox is checked.

If you need more info, or need help with something specific the TinyMCE docs tell you to do, feel free to mark this as active again.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.