1.12.x ckeditor.api.php hook_ckeditor_settings_alter(array &$settings, $format)
1.10.x ckeditor.api.php hook_ckeditor_settings_alter(array &$settings, $format)
1.11.x ckeditor.api.php hook_ckeditor_settings_alter(array &$settings, $format)
1.7.x ckeditor.api.php hook_ckeditor_settings_alter(array &$settings, $format)
1.8.x ckeditor.api.php hook_ckeditor_settings_alter(array &$settings, $format)

Modify the raw CKEditor settings passed to the editor.

This hook can be useful if you have created a CKEditor plugin that needs additional settings passed to it from Backdrop. In particular, because CKEditor loads JavaScript files directly, use of Backdrop.t() in these plugins will not work. You may use this hook to provide translated strings for your plugin.

Parameters

array $settings: The array of settings that will be passed to CKEditor.

$format: The filter format object containing this editor's settings.

Related topics

File

modules/ckeditor/ckeditor.api.php, line 165
Documentation for CKEditor module APIs.

Code

function hook_ckeditor_settings_alter(array &$settings, $format) {
  foreach ($format->editor_settings['toolbar'] as $row) {
    foreach ($row as $button_group) {
      // If a particular button is enabled, then add extra settings.
      if (array_key_exists('MyPlugin', $button_group)) {
        // Pull settings from the format and pass to the JavaScript settings.
        $settings['backdrop']['myplugin_settings'] = $format->editor_settings['myplugin_settings'];
        // Translate a string for use by CKEditor.
        $settings['backdrop']['myplugin_help'] = t('A translated string example that will be used by CKEditor.');
      }
    }
  }
}