Missing widget.js or iframedialog.js? It may be due to Ckeditor module's mysterious install process

Submitted by John on Tue, 05/24/2016 - 21:10

Here I go, still posting articles on Drupal 7, but hey, maybe someone will find these useful since that version isn't going away any time soon. Now how about a little SEO for the error message:

Uncaught Error: [CKEDITOR.resourceManager.load] Resource name "widget" was not found at "https://example.com/sites/all/libraries/ckeditor/plugins/widget/plugin.js".

Drupal's CKeditor module is an invaluable tool for crafting content. It's integration with modules like Asset and SCALD take your content from dry, to engaging. But as any Drupal developer may know, WYSIWYG's in general, can be a real pain to setup. It's nothing specific it seems, just rather an aggregation of small things, that aren't entirely intuitive. Remembering to check a box here, or just remembering to download the right version of the library. Today I came across another nuance to setting up CKEditor in Drupal 7. 

Here are a few lines from the install.php file of ckeditor.

//searching ckeditor.js
$ckeditor_path = _ckeditor_script_path();

...

  if (!empty($ckeditor_path)) {
    $arr['ckeditor_path'] = $ckeditor_path;
  }
  else {
    $arr['ckeditor_path'] = '//cdn.ckeditor.com/' . CKEDITOR_LATEST . '/full-all';
  }

The rest of the code goes on to save the contents of $arr to the ckeditor_settings table. It seems that this code can lead to some quite different settings depending on when exactly you download the CKEditor library. If you install the module before you download the library, then the version of CKEditor that is used will be some latest version pulled from the CKEditor project's CDN

This can be very confusing once you push your code up to a remote environment. Since the library was likely committed to your repository by that point, then the remote server will most likely be using the locally installed copy, which you might have assumed your local environment was using if you hadn't opened up your network inspector to see where those files were actually being pulled. If you were missing the files in the title of the article, then it's likely that the version you have installed locally isn't the full version of CKEditor, you downloaded the standard version by mistake. Or, if you do want to use the CDN version, and why not, fewer requests you need to serve, then go to the global settings page at admin/config/content/ckeditor/editg, and manually enter the CDN url for the Path to CKEditor.

Lesson learned, always download dependencies before enabling software. Especially when it is not enforced for you.

Since CKEditor is now available by default in Drupal 8. I guess this won't be an issue any longer, but to those fellow support developers out their still maintaining their Drupalk 7 sites, here's one to you.

 

Tags