Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When we were using the TinyMCE it was possible to override the init for the editor in the template.php file. Ie)
function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
if ($textareaname == 'field_foo_bar') {
$init ['theme_advanced_buttons1'] = array('plug1', 'plug2');
}
}
I've browsed the source code but I do not find anything similiar. Is it a no can do?
Comments
Comment #1
TwoDYou can use hook_wysiwyg_editor_settings_alter() in a similar way, but it has to be done in a custom module for D6 because it's no longer a theme hook.
There are various examples of its use here and there in the issue queue, but some if the first ones I put together are in #313497-52: Allow configuration of advanced editor settings.
Basically, to do the equivalent of the above, but per editor profile - as Wysiwyg module does not do any processing for individual fields:
Note that this will override what Wysiwyg itself set as value for theme_advanced_buttons1 based on the selections under admin/settings/wysiwyg/#/profile -> "Buttons and plugins".
This is a pretty powerful hook, but due to limitations in drupal_add_js() (
$settings
is passed via it to become JSON data) it's currently not possible to create JavaScript Function/Object references, Regular Expressions or use JavaScript constants in this hook. Strings, Numbers, Bools and Arrays/Objects with those are safe as they can easily be converted from PHP to JS.The alter hook is called from wysiwyg_get_editor_config() around line 550 in wysiwyg.module.
EDIT: Typo in function signature fixed, thanks etcetera9.
Comment #3
Sinan Erdem CreditAttribution: Sinan Erdem commentedThe code on #1 should be like:
"$context" instead of "&$context"