Drupal is a fabulous open source content management system for maintaining a web site. It has a large pool of additional software to support it. With Drupal you can create many kinds of websites from your personal homepage with a blog and forum to a complex corporate web site with an online shop. This article reviews the "Drupal 6 Themes" book written by Ric Shreves and published by Packt Publishing who sent me a review copy.
The actual content of a web site - the text - is surely very important. But to make your web site stands out from the millions of other web sites at the first glance it also needs a unique look. The look of a Drupal-powered web site is mainly controlled by themes. There is a number of themes that you can download and use for your own website. But if you need a look that reflects a corporate identity or want something otherwise unique then you need to create your own theme. Fortunately Drupal allows you to customize nearly everything - formatting, colors, content placement, icons and typography.
My personal Drupal background
While I have been creating and maintaining web sites since the early 90s I have been using many different tools. HTML editors, meta languages and even wikis. But nowadays I believe that content management systems (CMS) are the right tool for most web sites. At least for websites that focus on public information and communities (as opposed to intranets or special tools for developers). Actually I hesitated to use Drupal because I knew it was written in PHP and I personally dislike PHP as a programming language. I knew I would hardly be happy with a standard website and would customize it a lot. So I expected that customisation needs to program PHP and even look at other people's code.
What surprised me most was that even after weeks and months of using Drupal I still have not written a single line of PHP. And workaround.org uses several modules and customisations, a blog (migrated from Wordpress), views and taxonomy (for the articles section) and the book module (for the ISPmail tutorial). After the simple installation I could use and configure these modules online in the administration interface. Nice.
A customer then needed a simple web site with a few pages he could edit online which matched his corporate identity. I dared to recommend him to use Drupal and as he had no experience of content management systems it was hard for me to tell him why he should use it. Months later he was working on translations and started to appreciat further modules. The most interesting part was creating a new theme for him. I knew it was pointless to search for a similar theme on the internet as he had pretty clear ideas of how the site was supposed to look. So I read some basics about theming, decided to use the Zen theme (which is a basis for own themes) and pretty much just changed a lot of CSS and just a little HTML. But still I did not touch PHP.
Currently I am working on a website for a friend's aquaristic (fishkeeping) store. He needed a fish database (ubercart), different sections for jobs and the services he offers, a distinct front page with hand-picked articles (panels, views and nodequeue) sorted by date and - above all - a design matching his corporate identity. So once again I found myself working on a Drupal theme. But this time I wanted to do it right and first read the Drupal 6 Themes book to get an idea of what I can really accomplish with themes and how. So I started with a decent knowledge of HTML and CSS but with only basic PHP skills. [The new site is not yet launched so I don't provide a link.]
If Ric Shreves' book tought me one thing then it's that theming in Drupal is all about overriding. While I was searching for a nice theme for workaround.org I often came across beautiful themes that had some minor quirks like the text size or the title color. If I had read this book I knew that it had been trivial to just take a theme that was close enough to my ideas and override certain styles and functionalities. Overriding means that I take everything from another template and just change the aspects I want to look differently. That way I can install a new Drupal version and even a new version of the theme I am inheriting from. And I can override anything from certain CSS styles to the presentation of certain elements like nodes, book navigation or blocks. And there is large number of themeable functions that you can override like how breadcrumbs are rendered. What I like about the book is its reference on the standard PHP templates and the variables used therein in chapter 4. You want to override how a comment is rendered then check the book tells you to use the comment.tpl.php. And you also get a list of variables that Drupal makes available in the context of that template - for example $author is the name of the comment's author. Ric does that for at least all standard modules that Drupal comes with.
As expected the book explains how to create a new subtheme from the "Zen" theme. Zen is a basic theme that can be used as a basis for own themes. It is well documented and very complete. I had already done this on a basic level. Still I found a few details that I must have missed at first - like Drupal allows me to define additional regions. You are not limited to header, footer, content area, left and right sidebar. Just reserve space for a typical ad at the top of the page if you like. Chapter 6 deals with how to add CSS style sheets (and their precedences) and overriding the so called themable functions. This chapter is no reference for Zen but rather a nice walkthrough to understand how one would make Zen look the way you want.
While I'm happy starting with Zen I could of course also start creating a theme from scratch. Chapter 7 shows how to plan for a theme and where in the resulting HTML code each element is placed. Like the logo, the breadcrumb (navigation path) or the actual regions. Looking at other people's themes really scared me. But seeing how it all comes together bit by bit really helped me break down the HTML into understandable pieces.
In addition to chapter I think that appendix A is helpful, too. The CSS map shows which CSS files come with Drupal by default and which styles they provide. This will save investigating the files. It also makes the large CSS files of standard themes like "Garland" looks less scary.
What I liked about the book
There is obviously some online documentation about theming on the Drupal site. And it helped me getting started with customizing the Zen theme. But the book gave me a chance to step back from the work (and even from the computer). I tend to start skipping sections in the documentation I think that I understood already. But then I easily miss interesting details that would make my life easier. Aren't we all in a hurry when reading documentation for a project at hand? :)
What surprised me is that Drupal allows me to alter how nodes, forum posts, blog articles and everything else looks like. I knew I could override CSS styles and even add templates. But I wasn't aware how easy Drupal makes it for me to just change certain details I like to have differently.
The style of writing was really catching. You may know the effect that you are missing out basic parts when explaining a complex concept to a beginner. But the author is not skipping anything basic nor making the first chapter uninteresting. Even though I had dealt with customizing a theme I got a lot of understanding even from the first chapter. If you are remotely familiar with Drupal of course you know about blocks, sidebars and the administration menu.
Who will find this book useful
This book will teach you customize a Drupal-driven site and make it look exactly the way you want it to. But if you feel you can't yet create a HTML and CSS file and make that render in your browser properly then it's too early to buy this book. If you are just a graphic or screen designer lacking knowledge of how a web page is rendered then you will likely get disappointed.
Regarding the required PHP skills there is nothing to fear really. A lot can be accomplished with customizing the CSS alone. Even the placement of objects on a web page is nowadays partly controlled using CSS. If you want to alter what is in the breadcrumbs or navigational elements then you can change the HTML that is printed. The templates are much easier to customize than one might think. (Chapter 4 contains a handy reference on how to customize the output of the core modules.) And should you need to print certain parts of a page only on certain conditions then you can program PHP which basically just means using if/then/else statements with conditions based on built-in variables. Developing proper Drupal modules may be a little rocket science but theming existing modules and the core functionality is a cakewalk. Just override what you think should look different.
What I missed
At first I thought the author had missed to mention the typical tools that are definitely needed when developing themes. But they get mentioned throughout the book and explained in Appendix B. The modules that every serious Drupal user should know about are Devel, Views, Panels and CCK. Especially during theme development the Devel module is indispensable. It shows how to theme certain page elements and provides a helpful feature to create dummy content on a site to actually see how a theme would display content.
Well, okay, the book is about theming. But I can imagine that if someone gets asked to create a certain layout on a Drupal web site then it's vital to know which modules help with it. No theme can replace the Views and Panels modules. A more detailed explanation would be welcome here. I already knew about them but I can imagine that someone who is knew to the matter will not understand how powerful these modules really are and what purpose they serve.
Firebug and Web Developer are also tools I definitely recommend and use myself every day. Motivating the reader to use these tools by showing what they can do would have been great. Maybe by dropping in a screenshot pointing out the features. So if you intend to buy this book: check out Appendix B and install these tools right from the start.
At some occasions when reading examples in the book I wondered where I could find a reference of what else I can do. Like in the second chapter the author describes example PHP code like for displaying a certain block only to the administrator ($user->uid==1). It may be outside of the scope of this book but I wished I had found pointers or even a reference to what attributes $user or $node provides.
Similarly at other places of the book I had questions on my mind that were left unanswered. For example in chapter 5 there is an explanation of the search order for the page template. Drupal looks for page-user-1.tpl.php (if the user has ID 1) first. Then for page-user.tpl.php and if even that file was not found it loads the page.tpl.php file. I wondered where this logic came from. Can I do that in other parts, too? Will node-user-42.tpl.php work?
Some themes I found - like the complex Acquia Marina theme - have tons of theme-specific settings. I'm not yet sure how I would add such features to a theme. Like whether I want a fluid or fixed width layout. How breadcrumbs are supposed to look. The Color module (shipping with Drupal and used in the default Garland theme) was introduced in the first chapter but somehow I missed information on what it does and how I could use it to let the site administrator change the colors in my theme.
And finally I had wished for a non-technical chapter on good web design. I know it's probably too wide a subject. Looking through the collection of Drupal themes on the net I found many ugly and unbearable themes. There are some basic psychological effects like the reader's eye is drawn to white spaces on the screen… the navigation should be clean… the sidebars should not distract from the actual content… don't mix colors of similar contrast like red text on a blue background. It's interesting to see how many themes break these simple rules. Drupal has a lot of functionality. And it's easily overused. But - admitted - it's probably outside the scope of the technical approach on themes in this book.
If you have toyed with Drupal, know about its basic concepts and have a thorough knowledge of HTML and CSS then this book will give you everything you need. Just don't expect much non-technical help on creating beautiful themes. That's your own responsibility.