0

Below is my module.info file:

name = myid
description = Creates an ID template, Inputs ID form, Prints an ID and View System Statistics .
core = 7.x
package = CSU

;Jquery Library
dependencies[] = jquery_update (>=7.x-2.5)

;Needed to create text editors.
dependencies[] = imce (>=7.x-1.9)
dependencies[] = wysiwyg (>=7.x-2.2)
dependencies[] = imce_wysiwyg (>=7.x-1.0)

I know required module of my custom module can be declared in my module.info file to inform module users that it depends on it. How about javascript library like TinyMCE? Is it possible to declare it at hook.info? How will I inform that the user must also download TinyMCE.

I was thinking of including it using drupal_add_js but Tinymce is always stored at drupal\sites\all\libraries\. Please enlighten me in my problem. I'm a bit lost.

  • 2
    drupal will automically download and install it. Do you mean drush can download the dependencies automatically? I remember that Drupal core does not has this feature. – Jimmy Ko Jul 29 '16 at 8:22
  • 1
    @JimmyKo Im sorry, I need to clarify my post. I just wanted to instruct drupal at hook.info that it needs/depends on the TinyMCE library or simply declaring it in hook.info that the user must also download TinyMCE library. – user46175 Jul 29 '16 at 8:28
  • @JimmyKo --> please see my updated post. – user46175 Jul 29 '16 at 8:43
1

You can define library dependency using hook_requirements(). Then if the library is missing, drupal will automatically shows the error message in status report(admin/reports/status).

Also it will show the error message, when trying to install module without having required library.

You need to define hook_requirements() in your youmodule.install file like below:

/**
 * Implements hook_requirements().
 */
function yourmodule_requirements($phase) {
  $requirements = array();

  if ($phase == 'runtime') {
      $t = get_t();
      $library = libraries_detect('tinymce');
$error_message = isset($library['error message']) ? $library['error message'] : '';

if (empty($library['installed'])) {
  $requirements['tinymce'] = array(
    'title' => $t('TinyMCE Library'),
    'value' => $t('Not installed'),
    'severity' => REQUIREMENT_ERROR,
    'description' => $t('!error Please download !tinymce, and extract it into the %directory directory.', array(
        '!error' => $error_message,
        '!vimeo.ga.js' => l($t('TinyMCE'), $library['vendor url']),
        '%directory' => 'sites/all/libraries/tinymce',
      )
    ),
  );
}
else {
  $requirements['tinymce'] = array(
    'title' => $t('TinyMCE Library'),
    'severity' => REQUIREMENT_OK,
    'value' => $t('Installed'),
  );
}
  }

  return $requirements;
}
| improve this answer | |