University of Oregon

Drupal – adding debug messages to your custom module – Improved

As a follow up to ‘Drupal – adding debug messages to your custom module‘. I improved the code and wanted to share. Now you can drop in a few functions and add one line to your hook_admin_settings function to get debugging functionality. If you want to start with a baseline of functionality you can also update each of your functions to declare themselves in the debug messages. Which is handy for tracking down issues. In the end you get the same addition to your GUI with control over how and when debug messages are used. Screen Shot of the new checkboxes You also get the same reporting output, to the screen, watchdog, or both: Here’s a quick look at my watchdog log gui with both types of error reporting enabled: Screen Shot of watchdog screen All done with cleaner code. (more…)

Drupal – adding debug messages to your custom module

Note: There is a follow up post here: Drupal – adding debug messages to your custom module – Improved
I work with a few custom modules and lately I’ve been migrating one from PHP 5.2 to 5.3 & Webform 2 to 3. It’s been a challenge to sort out where some of the the errors are being generated from so I added a grip of debugging statements. In fact, I used a regex replace to log the name of each function that’s run in hopes that I could track down errors in chronological order. That worked OK but I though I may want to turn it off or switch from drupal_set_message() to watchdog() calls when it’s ready to go to production. So I wrapped each log item in an if statement and tested for two new module variables:
  • Enable debugging message feedback
  • Enable watchdog debugging feedback
So now I have some GUI control over how and when debug messages are used. Screen Shot of the new checkboxes (more…)

Updated Links content type to use fully qualified links to admin user

I updated the Links content type to use fully qualified links to admin users. The links content type allows us to embed links as nodes in our site structure. Which means a link can be an entry in a book or menu. This is particularly useful when we want to link to an internal page with out duplicating the content. A good example would be on the new Employee Relations page; we have included a link to FMLA under the General Information menu.
Screen shot

Employee Relations Menu View

That FMLA link (/links/family-medical-leave-act-fmla-0) exists in a dynamically generated and themed book menu and the node itself is a Link content type. The node contains the Link Title, Link URL for the FMLA page (/content/family-medical-leave-act-fmla-0). Regular users are redirected immediately to the fmla page but administrators are given a preview of the link. (more…)