PHOBOSLAB

Blog Home

How Not to Build a Page with Drupal

A few weeks ago I was asked to build an Intranet-Site for a small company. Nothing too fancy – just the usual groupware stuff like News, Calendars a Blackboard etc. I was given some Photoshop Files which were easily translated to XHTML. The layout was already approved by the client so this step was pretty much a no-brainer.

I always wanted to try out the Drupal CMS and figured this Intranet-Site would be a perfect fit for it. Drupal was developed with community sites in mind; every aspect of it was designed support the extensive built in User and Rights management. Just what I needed.

My XHTML file was quickly adjusted to function as a Drupal template. Not everything was working right from the beginning, but I figured I’d first work out the hard stuff and care about these “small rendering bugs” later. So I carried on to build my content – which is where my odyssey started.

In the Module Maze

Drupal heavily relies on modules. Figuring out what you want to do is one thing, finding the right modules to do it with is quite another. Between the nearly 3000 available modules I stumbled over something which seems to be almost a standard (correct me if I’m wrong) for all Drupal sites: CCK, the Content Construction Kit. With it, you can click together new content types without touching any code. Sounds promising. About 30 minutes and a dozen installed modules later, I found myself with a working calendar which accepts dates from my newly created event content type. Not too bad.

The visuals of the calendar of course didn’t exactly fit the rest of the site. No problem I thought and searched for the calendar template… which I didn’t find. All of its HTML code is echoed directly from within a PHP file (oddly disguised with a .theme extension) just like in the good old 1990s. There was however a CSS file with some 50odd classes to have fun with, which is good but not always enough.

Delicious Breadcrumbs?

My real problems however started, when I tried to get the breadcrumbs menu working. There are numerous ways to organize your pages within Drupal – the most important one being the taxonomy system – which I head to read 4 articles about, stuffed with words like vocabularies and terms, to finally figure out what exactly it is. One got it straight: The taxonomy system works like categories, only that pages can be assigned to multiple categories instead of just one. Thank you.

This taxonomy thing sounds flexible, but also renders breadcrumbs basically unusable. What is the correct breadcrumb path of an article residing in the A/B/C and the D/E/F category? Of course, there are again dozens of modules “fixing” this problem with which you can, for instance, enter the complete breadcrumb path for each node you create. Wait, why am I using a CMS again?

I had similar problems when building the menu structure – the menu items didn’t highlight when you’re in the corresponding category, only the submenu items did. Also, defining which menu to display at which location was tedious. Maybe I was just missing something…

And the answer was so near

After two more hours of searching and reading, I finally gave up and built the page with my own CMS. I quickly wrote the missing pieces (like a calendar) myself and finished the page in just a few hours. This of course is an unfair comparison, because I know my CMS in and out, which is exactly my point! Drupal isn’t bad – it can do many things quite well. Drupal isn’t easy – there’s lots and lots of stuff to learn and understand to build a page with Drupal as you intended to. Drupal also is complex – if you want to do something it isn’t built for, you have to know quite a lot about its inner workings.

Don’t underestimate the cost of learning a new system. I’m not saying you should go through this world blindfolded. However, especially on time critical projects, it is in most cases better to go with something you know well and program the pieces you need yourself, instead of having to learn a new library, framework or CMS. Don’t “reinvent the wheel”, just build one to perfectly fit your vehicle.

Wednesday, February 13th 2008
— Dominic Szablewski, @phoboslab