Trevor James writes "Piling up on my tech bookshelf are a bunch of excellent titles on the Drupal content management system. Earl & Lynette Miles Drupal's Building Blocks is the book on how to use the CCK, Views and Panels modules. It's part of Addison Wesley's Developer's Library and is the definitive guide to the 'trifecta' of Drupal modules. There's a lot of theory and concepts explained in granular detail here as well as recipe style tutorials — soak it up. It's an excellent resource." Read on for the rest of Trevor's review.The second book and the subject of this review is Karthik Kumar's engaging Drupal 6 Theming Cookbook, recently published by Packt Publishing, the prolific open source publisher. It's a richly detailed hands-on guide to theming Drupal 6 Web sites. I recommend this book for anyone who is beginning their exploration of Drupal front-end theming and theme design. Though the book is focused on Drupal 6, the application and concepts of theming can be applied to Drupal 7. Where Miles' book is focused on each and every detail of the trifecta modules, Kumar's book takes a streamlined approach to teaching Drupal theming, using hands-on exercises. This will appeal to those who like to learn-by-doing.
First, a brief explanation of what Drupal is: simply put, Drupal is a popular open source CMS used by thousands of small & large scale businesses, non-profits, education & academic institutions, and federal government agencies. Drupal has seen a rise in popularity and interest lately due to its brand new version release (Drupal 7) and the successful and well attended DrupalCon 2011 Chicago. The Drupal community is already planning the next release, Drupal 8. There's lots of Drupal going on.
Kumar's book is geared towards Drupal 6 users who want to learn how Drupal themes are built; Drupal Web site managers and webmasters who want to customize their Drupal themes; and Drupal developers who are looking to bring their front-end development to the next level. Through easy-to-follow "recipe" style tutorials, the book teaches you how to implement basic, intermediate and advanced Drupal theming concepts, solutions and functionality. You learn how to tweak contributed Drupal starter themes as well as how to roll your own custom Drupal themes.
Drupal 6 Theming Cookbook expands the existing documentation on Drupal theming that's already provided both on drupal.org (Drupal 6 & 7 Theming Guides) and in other recent Drupal publications including Pro Drupal Development and Front End Drupal. Where those titles are exhaustive studies of front and back-end Drupal development, this book focuses purely on front-end theming and presents this in one comprehensive volume of examples and demos. Bear in mind that the book is focused on Drupal 6, however many of the concepts outlined in the book will be similar for Drupal 7 and can easily be applied to the latest Drupal version.
Each section presents sections of clear instructions divided by headers. These model headers flow through the entire book: Getting ready, How to do it, and How it works. Sections present bulleted list of instructions so you can easily follow along step-by-step. Screenshots are clear and the text flows smoothly. The click-able buttons and links in the Drupal administration screens that the author refers to are highlighted in bold to denote an action the reader needs to take.
The book starts out covering the basics of the Drupal theme system and shows us how to manipulate and configure Drupal themes via the internal Drupal site administration screens. Installing themes, uploading logos, favicons, adding slogans, user and administration enabled themes, and block content. New Drupal users will benefit from the overview of the Drupal admin screens and concepts like adding blocks to regions of a theme, and displaying blocks on specific pages of your site. For intermediate users, there are examples of adding PHP code into blocks to allow for specific functionality.
The author continues building up from theming basics. The author explains the anatomy of a Drupal theme explaining what page.tpl and theme.info files are and why they are important for themers. You get practice overriding a core Drupal theme by creating a sub-theme based on the core. This is a great method of introducing theming since you get writing some basic code but can easily leverage much of the theme code in a core Drupal theme such as Garland or Minnelli.
Recipes start showing more theme code and covers essential theming concepts like CSS optimization — this is timely considering that IE browser versions still only support a maximum number of style sheets, so when you theme and implement your CSS in Drupal 6 Web sites you'll need to take this into consideration.
As a bonus you learn how to write a custom Drupal module to hold theme overrides, so you're getting a good foundation and intro to Drupal module development in this book as well. The author shows us how to add a CSS file via the custom module using the drupal_add_css() function. This is a great way to introduce Drupal users to the Drupal API.
The author turns attention to building a custom theme using the Zen contributed theme as your starting point. The Zen theme bills itself as the "ultimate starter theme" for Drupal 6 sites. The author shows us how to configure a custom theme using the Zen starter theme code. Zen is actively maintained and in development for Drupal 6 (by members of Palantir and Lullabot) and there is a development version for Drupal 7. This theme is still a valid and recommended starting point for beginning, intermediate and advanced Drupal themers. Kumar covers using the Zen theme as a starter theme to build our own custom theme; adding background images via CSS; Adding conditional style sheets for IE; how to remove base theme configuration settings from the theme-settings.php file.
Chapter 4 starts getting into more intermediate and advanced level theming by showing us how to create custom template files. In this chapter you learn how to use and implement page.tpl.php; customize node types using template files, for example creating a node-story.tpl; overriding a specific node; using the Devel and Theme Developer modules; and overriding themes using Theme Developer module.
There are many details in here including using the theme developer module to view all template variables and candidate template names available to you. Specific recipes include:
- Overriding the Drupal user name with the user's real name either using custom code or via a the contributed module RealName.
- Changing the core site maintenance theme and override maintenance template so your site maintenance page uses your custom theme instead of the drupal default
The author covers best practices for development and debugging. The author shows us a large list of theming tips and tricks including:
- Using Firebug & Web Developer Extension
- Searching for Drupal functions via the Drupal API
- Executing PHP code with Devel module
- Adding debugging code in a custom module including dpm and dsm
- Editing CSS and HTML and validating CSS using Web Developer extension
The second half of the book (Chapters 6-12) covers advanced theming. Recipes include:
- Adding variables to node templates
- Adding preprocess function to remove search box and feed icons on the front page of the site
- Adding a preprocess function to template.php that hides all the theme regions; page title and the submission info on the front page of the site
- Using functions like format_interval to format the date and time on the site
Since Drupal is largely built with forms and displays forms widely throughout it's administration screens, the recipes devoted to form design and theming are a wealth of info for themers. The author scopes out:
- The form API and how to use it
- Altering forms; locating form ID and using hook_form_alter()
- Modifying the default body element in node forms
- Enabling and configuring the WYSIWYG module
- Reordering fields and form elements — for example moving the tag categories and the menu items below the body text area
- Overriding the node form Save and Preview buttons with an image icon vs. the default Drupal submit button.
The book covers CCK module related functionality. There's lots of information on image handling; the ImageCache module and integrating Lightbox modal windows here.
Detailed recipes on theming the trifecta modules are included, specifically dealing with Views theming and creating custom View template files and overriding the table style plugin using templates. The Views module is presented in detail — how to configure Views and display output using various Views plugin styles. Anyone using the Views module for the first time will get a lot out of these later sections.
The book concludes with a look at theming the trifecta modules, covering Panels module theming and overrides in depth.
With these concluding chapters on the CCK, Views and Panels modules, Kumar's book provides a perfect twin to the Miles' Building Blocks title. Both will help to teach Drupal theming and module configuration to a new generation of Drupal users, themers and developers.
Trevor James is a Drupal developer & themer based in Middletown, MD, USA. He has authored two books on Drupal."