Join the Conversation

Join the Conversation

Sign up today to hear about books and authors from an independent bookstore near you.

Drupal Flexibility and Core Hacks

As Gina kindly pointed out to me recently, my blog promises overlong tangents about Drupal, but hasn't delivered lately. Since my first-year anniversary of working with Drupal is coming up, I thought I'd change that and share my experiences so far.

I came to Drupal as a PHP/MySQL programmer and a bit of a snob about building sites from scratch. My primary concern was that a mature CMS would be too constricting, that it would keep me from doing things I wanted to do, or else those things would require complex, time-wasting workarounds.

I'm really happy to say, I was wrong.

Drupal is a fantastically flexible system, and don't believe anyone who says otherwise. Anything is possible in Drupal. You can modify it to work however you like, and on the whole, it's so flexible that you should be able to easily implement whatever you need on top of what's there. Rather than feeling constrained by the core CMS, I've found it liberating, saving me the time and effort of hand-coding a lot of backend stuff like edit pages, logs, and other admin screens that are, frankly, really boring to do. It's very easy to take what you've got in core Drupal and add your own stuff on top of it...much easier than rolling your own CMS from scratch.

The only big no-no is hacking core Drupal. Core Drupal refers to the main drupal distribution itself, which includes the main framework and six required modules (block, filter, node, system, user, watchdog), plus several optional modules. Hacking core Drupal can cause your site to fall out-of-sync with important security updates, as well as adding a significant risk of future malfunction.

On, I've made one significant hack to core Drupal. One. Here it is:

user.module line 311:

if ($file = file_save_upload('picture_upload', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid .'.'. $info['extension'], 1)) {

changed to:

if ($file = file_save_upload('picture_upload', variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid .'-'. time() .'.'. $info['extension'], 1)) {

This code simply appends a timestamp to a new user picture when it's uploaded. Otherwise, the new user picture has the same filename as the old user picture, which means many browsers won't automatically refresh the picture, causing the user to think the upload didn't "take." Confusing!

This is a RARE example of the kind of thing that can't be circumvented. Almost anything else can be modified without hacking core Drupal.

I'm going to start blogging at more length about how I've set up certain features of this site, because I think it might be helpful to other Drupal users out there. Googling for such blogs was certainly of enormous help to me when I was getting started...and still is today.

Want to know more about a certain topic? Ask me--I'll write what I know.