Category Archives: Drupal Modules

How-to for Drupal Modules

Configuring CSS for the Drupal 7 Admin Area

To configure CSS for the Admin Area, you have options. You can use the css_injector module, or simply modify an existing css file.

Regardless of the location you are going to store the css, to modify the administration are, use the class .logged-in to target the backend. Example:

.logged-in #container { background: orange ; }

The previous css definition would cause the background of the administration overlay area to be displayed as orange. Using .logged-in, you can target any area of the backend.

Setting default level of editor for Drupal 7 wysiwyg

From the wandering that I did for setting up the default level of wysiwyg editors, I found it is not clear how to set the default level of wysiwyg editor filter. I found several explanations. Many explanations exist, the explanations were outdated and therefore incorrect. Many suggestions used extraordinary methods of PHP to accomplish the task. If done correctly, with Drupal 7 and latest modules (available 2/18/2014), the task is trivial.

To set the default:

  • Install and activate the wysiwyg module
  • Install and activate the wysiwyg editor that you prefer
  • Set up the wysiwyg editor to offer the correct features for Filtered and Full option versions
  • Go to the administrations Text Formats page (admin/config/content/formats)
  • Move the level you prefer to the top of the editing levels list
  • Save changes

Warning: if you load the PHP Filter module, it automatically loads the PHP Filter option to the top of this filters list and becomes the default. Probably, if you have multiple level people logging in, this is a problem. If you have roles that do not allow PHP Filter level editing, when they login, people without PHP Filter available will be locked out of the editor because they do not have authority to use PHP Filtering. Be certain to go to the Text Formats page and adjust to move the PHP Filter off the top of the stack of editors.

Debugging Drupal Module Creation

Drupal

If you are in the process of creating a module for Drupal, you may want to activate debug messages to give you a heads up on what may be going wrong. If you would like to activate debug messages in your Drupal module development, add the following to the settings.php file:

  • error_reporting(-1) ;
  • ini_set(‘display_errors’, TRUE) ;
  • ini_set(‘display_startup_error’, TRUE) ;

Remember to remove this from your production site. ◕‿◕

Drupal 7 error: version of CKEditor could not be detected

Drupal

If you are running Drupal 7 and trying to install the CKEditor, you may find an error message.

You may find the message that “CKEditor could not be detected” when you visit the wysiwyg module. Looking throughout the net, I found that lots of people have found this error. It seems it has happen various times that CKEditor updated their code. After trying several “fixes” found on the net, I found each was for different version of CKEditor than I had download. Even the latest suggestion that the error was trivial to fix by adjusting wysiwyg module’s version detection did not solve the problem. Some fixes resulted in white screens and were a pain to recover from. After trying several time consuming fixes (most of the time spent trying to find the fix), I decided to downgrade to a working version of CKEditor.

You may want to try installing the latest version of CKEditor with the latest version of wysiwyg module, the problem could be resolved with any update of wysiwyg module. However, if you find the problem, you may want to simplify your fix by a downgrade to CKEditor 3.6.6.1 (found at the bottom of the linked page). This 3.6.6.1 is available, will load without problems with wysiwyg module as late as 7.x-2.2, and will probably do what you need … provide a wysiwyg editor.

PS … if you are installing, make certain you do not activate the ckeditor module and wysiwyg module. Activating both modules will result in an error.