Drupal has seen a number of books written about it in the last 18 months or so, the sign of a healthy platform. The latest of these books is Drupal 5 Themes, by Ric Shreves, published by Packt Publishing. The book covers the process of making a Drupal site look how you want it, known as theming. Theming Drupal is a multi-step process, due to the flexibility and customizability of Drupal itself. This book serves as a fine introduction to the process and methods of Drupal theming; however, it is not without its rough patches.
The book is lean, right around 250 pages, and even that is including a completely superfluous appendix, and some other sections that could have easily be kept out without too much loss of content. Starting out with the obligatory and well done introduction section, we quickly move right in to customizing the themes that come with Drupal, and how to install a contributed theme. While we could have done without the hand-holding as we look at the basic parts of theme configuration, it is a fine introduction to the amount of configuration possible without delving into theming itself. The author takes us through a fictional client’s requirements for a site, and shows how those design elements would be implemented in Drupal, without writing any code.
A brief discussion of the various theming engines that are available is suitably brief enough, as Drupal theming today revolves around PHPTemplate, and, soon, it’s time to start delving into Drupal’s custom templating language. PHPTemplate was written specially for Drupal, and it deftly balances flexibility and power, as it remains easy for developers and designers alike to work with it. Some discussion of block visibility serves as a good example of those places where Drupal allows developers to get down into code without modifying Drupal itself. While it’s a fine discussion, the author fails to mention the , which has lots of other examples for a budding themer to snack on.
We also get a very good idea in Chapter 3 on how just a little bit of well-placed code here and there can make a big difference in Drupal themes. Working with the , the author takes us through the theme’s files to show where the key points of control lie.
Chapter four is a list of core css files and theme functions. It is also completely superfluous. It could be replaced with a couple of grep or find commands, or a tutorial for finding theme functions on , which would have longer-lasting benefits for a Drupal themer. A representative of the content in this chapter is:
theme_admin_block_content
Formats the content of an administrative block.theme_admin_page
Formats an administrative page for viewing.
It’s 18 pages of your life that you’ll never get back.
That’s followed by what is easily the standout section of the book. Chapter 5 is all about overriding css and theme functions, and is a terrific discussion on what’s available to the themer, and how to get at it. It’s chock full of great information and examples, showing how the default “Garland” theme takes the PHPTemplate engine and overrides parts of it itself, and shows how you and your theme could do the very same thing. It’s an empowering overview of taking control of the theming process.
Chapter six focuses on designing a theme around the Zen, creating a subtheme. Just a bit of code and some new CSS, and we have a completely different looking site. The big problem here is that the theme we come up with is pretty ugly. Nevertheless, it does show how big results can come from a little tweaking.
Now that we’ve taken a pre-written theme and designed a subtheme around it, Chapter seven is all about creating a theme from scratch. Starting with the bare basics and moving into discussions of what variables PHPTemplate makes available, and even how to make your own variables available, this is a grand discussion that shows the full power of the templating engine and how much power is actually there. Again, though, what we’re creating won’t be winning any design awards, but I suppose that’s beside the point.
The last chapter is about theming the various forms in Drupal, and this again is excellent. There are several steps in the process that can be used to change how forms work, and the author expertly goes through each way, showing where each one is most appropriate, and showing fine examples in the process. If the whole book were this well written, it’d be a bible of Drupal theming. Unfortunately, it’s not. The chapter also devolves into unneeded screenshots of most of the Drupal forms, and what functions are used to build them.
The book ends with a totally unnecessary appendix of every CSS selector included in Drupal core. Once again, a nice grep command could easily have been used to build this content.
hook_theme(), and in the removal of _phptemplate_callback(). Readers coming to Drupal 6 with this book would be well-advised to keep the appropriate open in a tab while reading and experimenting.There are great parts of this book, and there are horrible parts of this book. While I think that there’s more wrong than right, the parts that are right are very right and worth the price of the book. Someone new to Drupal theming, someone who’s just not sure what to do, someone who thinks they can just change the color in Garland or mess with Bluemarine and call it a day, these people will get a great deal of worthwhile information out of the 250 or so pages. The book is geared towards people with a good background in HTML and CSS, and it does mention that a ‘basic’ knowledge of PHP is helpful. It’s to PHPTemplate’s credit that most themers won’t need to touch too much code, and what needs done is typically simple logic and not difficult. Those places where you can get deep in to PHP and Drupal coding are properly glossed over. Drupal 5 Themes leaves room for an advanced theming book, and that is the appropriate time to have such discussion.
All in all, I do recommend this book to people who are looking at Drupal and want to know how they can change the look of it to fit their design. It does show the power of the Drupal theming layer, and how much Drupal’s output can be changed through, not just CSS, but some simple and well-placed PHP code as well. Drupal 5 Themes is a worthwhile introduction to Drupal theming, and deserves its place among the current crop of Drupal books.