0

I am building a custom plugin. I have the WYSIWYG module 7.x-2.x-dev. I have followed the instructions here.

I realize that this question is similar to this and this. However I think this may be a slightly different issue so I am going to try a new thread.

Pertinent code:

<?php
/**
 * Implements hook_wysiwyg_editor_settings_alter().
 */
function my_module_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
  $settings['extraPlugins'] = 'my_plugin';
 }
}

/**
* Implements hook_wysiwyg_include_directory().
*/
function my_module_wysiwyg_include_directory($type) {
switch ($type) {
  case 'plugins':
    // You can just return $type, if you place your Wysiwyg plugins into a
    // sub-directory named 'plugins'.
    return $type;
 }
}
/**
* Implementation of hook_ckeditor_plugin().
*/
function my_module_ckeditor_plugin() {
 $module_path = drupal_get_path('module', 'my_module');
 $plugins = array();
 return array('my_plugin' => array(
  'name' => 'My Plugin',
  'desc' => t('Custom plugin to add button styles in the WYSIWYG.'),
  'path' => $module_path . '/plugins/my_plugin/',
 ),);
}

/**
 *  Implements hook_wysiwyg_plugin().
 */
function my_module_wysiwyg_plugin($editor, $version) {
 switch ($editor) {
  case 'ckeditor':
   $module_path = drupal_get_path('module', 'my_module');
   return array('my_plugin' => array(
    'filename' => 'plugin.js',
    'path' => $module_path . '/plugins/my_plugin',
    'buttons' => array(
      'style_1' => t('Style 1'),
    ),
    'load' => TRUE,
    'internal' => FALSE,
  ),);
 break;
 }
}

This produces a blank area where the CKEditor should be and the error logs still say that it is looking in the sites/all/libraries/ instead of my custom module folder. Any ideas on what I am missing?

1 Answer 1

2

Turns out the tutorials and answers were wrong (at least for my set up/needs) The extra hooks and $settings['extraPlugins'] = 'button_styles'; were probably causing conflicts. I removed all but this;

function MY_MODULE_wysiwyg_plugin($editor, $version) {
switch ($editor) {
  case 'ckeditor':
    $module_path = drupal_get_path('module', 'MY_MODULE');
    return array('my_plugin' => array(
      'path' => $module_path . '/plugins/MY_PLUGIN/',
      'buttons' => array(
        'style_1' => t('Style 1'),
      ),
      'load' => TRUE,
    ),);
  break;
 }
}

and now it recognizes my plugin.js.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.