Drupal 7.x

Modify Drupal 7 text field maximum length

When creating a text field in Drupal 7, you must a choose a maximum length for your data. As soon as you create any data for this field, the maximum length become immutable in the Drupal field settings.

It's understandable that this would be disabled for decreasing the maximum length because it could results in a loss of data, however, it should be possible to increase the maximum length for any field.


Drupal Security at Drupal Camp Wisconsin

Today a presented on Security and Drupal at Drupal Camp Wisconsin. Great group with great questions and feedback afterwards. Here are the slides in PDF form for those interested.

Drush PHP Memory Limit

I was banging my head against the wall this morning because Drush kept telling me that I was exhausting PHP's memory at 128MB. I finally figured out the problem and thought I'd share for others searching the internet for a solution.

The first thing I did was check my php.ini file. Sometimes PHP on the command line will use a different php.ini file than the Apache version. In my case, the php.ini file is shared for both.

Render a Single Field in Drupal 7

I needed a simple method to render a single field from a node object in Drupal 7, but couldn't find any good answers by searching the web.

Here is the solution I finally came to by searching the documentation:

  // Render the field named "field_image"
  $field = field_view_value('node', $node, 'field_image', $node->field_image[$node->language][0]);
  print render($field);

Learn to Develop Drupal Modules with the Examples Project

If you are looking to learn the Drupal API so you can develop your own modules, check out the Examples for Developers project. It includes highly commented example code covering some of the most common features of Drupal. Versions exist for both Drupal 6 and 7.

Organizing your theme files in Drupal

When working on a large Drupal site, your theme can become quite complicated with dozens of templates or template overrides, images, css files, javascript files and even a massively large template.php file. Sometimes all these files will get dumped into the root of the folder making specific files difficult to find.

Here are some best practices when organizing your theme folder to make things easier to find.

CSS, Javascript and Images

Keep these files in separate folders like so:


or you may want to organize them into an assets folder like this:


Template Files

Put all your template files into a templates directory, then further separate them by the base template type (ie. page, node, block, view).

Altering urls in Drupal

One of the great things about Drupal's taxonomy system is that category lists are generating automatically, just by tagging your content. The taxonomy module, creates a listing of the most recent nodes in each category using a path like taxonomy/term/23.

The Views module will allow you to override this default taxonomy listing and soup it up to your tastes.