module

Drupal form and module debugging

Drupal debugging FAQ: How can I debug my Drupal form and module development process?

I should know more about this over the next few weeks, but if you're developing Drupal forms and modules, I've found the PHP error_log function and the Drupal watchdog function to be very helpful. They both let you log errors 'somewhere', and the error_log output shows up in your Apache logs, and the watchdog output shows up in your Drupal reports.

Here's how you call the PHP error log function:

Drupal developer modules

Once you get into serious Drupal module development, you'll realize that it would be really helpful if you could do several things during the module development process, including clearing the cache, rebuilding the menus, error logging (logging errors to a file, in particular), and so on. Fortunately, with Drupal's really large developer ecosystem, other Drupal programmers have already created some great modules to help you along in the coding process.

Here's a list of the Drupal developer modules I currently use, or have used.

Drupal form default input focus

Drupal form FAQ: How do I get default input focus on a Drupal form field (presumably a form textfield)?

There may be a better way to do this, but here's what I just did to get default input focus on a series of Drupal form 'add' and 'edit' pages. I just included the following Drupal form suffix definition on any form where I wanted to control the default input focus:

25+ Drupal form and module programming examples

This page serves as an index to all of my Drupal module, form, and databases tutorials and examples. In an effort to help supplement the documentation on the Drupal.org website, over time I hope to have good examples for every Drupal module and form problem you'll run into.

A Drupal 7 form table example

If you're interested in building an HTML table with Drupal, Drupal 7 in this case, here's a quick example of how this can be done.

My Drupal "theme table" approach currently provides the following functionality:

A Drupal get user id function (uid)

Just a quick note here to share a Drupal get user id (uid) function. I've found that when I'm developing a Drupal module or Drupal application, I often need to access the user id, so I created this simple function and include it in a common utilities module:

# return the current drupal user id (uid)
function get_user_id() {
  global $user;
  return $user->uid;
}

As you can see, the code accesses the global Drupal user object ($user), then gets the uid from the user object.

Huge Drupal Boost module performance improvements

Summary: A review of the Drupal Boost module, which dramatically improves website speed/performance.

Over the last few weeks I've been spending a little time every weekend trying to improve the performance of the devdaily.com website. I didn't think there was much of a performance problem with the website, but the Google Webmasters' site kept reporting that the site was slow compared to most internet websites.

PHP warning - Unable to load dynamic library ./apc.so (Solution)

While installing the PHP APC opcode cache, I just ran into the following error:

PHP Warning:  PHP Startup: Unable to load dynamic library './apc.so' - ./apc.so: 
cannot open shared object file: No such file or directory in Unknown on line 0

I found this error message in my PHP error log, but depending on your configuration I think it may also be in your Apache error log file.

Drupal canonical meta tags for pager URLs

As a quick note, I was just about to write a Drupal 6 module to add "rel=canonical" meta tags to Drupal pager pages (pager URLs), so URLs that look like this:

http://www.devdaily.com/blog?page=47

or this:

The Drupal fieldset collapsible syntax

Drupal fieldset FAQ: What is the syntax to make a Drupal fieldset (form fieldset) collapsible?

To make a Drupal form fieldset collapsible, just add the "#collapsible" attribute to your Drupal form definition, like this:

Syndicate content