Forgot your password?
typodupeerror
Image

Book Review: Drupal 6 Theming Cookbook 21

Posted by samzenpus
from the read-all-about-it dept.
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.
Drupal 6 Theming Cookbook
author Karthik Kumar
pages 384
publisher Packt Publishing
rating 9/10
reviewer Trevor James
ISBN 1847198686
summary For anyone who is beginning their exploration of Drupal front-end theming and theme design
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

The author shows how to use javascript with themes; and gives us recipes on manipulating the Drupal navigation system.

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
  • Disabling the javascript resizing of the body text box and using hook_form_alter to add specific # of rows and columns for the box
  • 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."

You can purchase Drupal 6 Theming Cookbook from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

*

This discussion has been archived. No new comments can be posted.

Book Review: Drupal 6 Theming Cookbook

Comments Filter:
  • Drupal 6? (Score:4, Informative)

    by Slashdot Parent (995749) on Wednesday April 13, 2011 @02:52PM (#35810894)

    Correct me if I'm wrong here, but cookbook-type books are generally intended to provide code samples and ideas that will work out of the box.

    Drupal releases updates pretty aggressively. Why would you want a Drupal 6 cookbook when Drupal 7 is already out? The review mentions that the two releases are similar, but so what? Drupal 6 code may still run, but surely best practices have changed from Drupal 6 to Drupal 7.

    At the present time, a cookbook on Drupal 6 is about as useful as a poopy flavored lollipop.

    • Re:Drupal 6? (Score:4, Informative)

      by Jeremiah Cornelius (137) on Wednesday April 13, 2011 @02:57PM (#35810950) Homepage Journal

      Drupal 7 changes themeing, almost entirely. 6 still had elements like "Left Column" and "Right Column" - whereas these are now numbered regions, which can be dynamically rearranged, without saddling publishing location of a block to a spatial location.

      Theme Drupal 6? This was timely in 2009.

      • by KoolyM (602345)
        Technically speaking, Drupal 6 does not have elements like "Left Column" and "Right Column". If you base your themes on the Zen base theme, you can have whatever "column" you want. I'm assuming (I'm not a themer with in depth knowledge on the subject) this is because Drupal 6, too, has a notion of regions. There's probably a lot you can learn from this book that will still be applicable to Drupal 7 (the differences aren't huge). That said, I don't see why they didn't just do a quick rewrite to incorporate
    • by _xeno_ (155264)

      Drupal 6 code may still run, but surely best practices have changed from Drupal 6 to Drupal 7.

      Drupal 6 modules might still run with fairly minimal changes, but they completely changed the theme system.

      I lucked out with my theme in that I was able to just ditch the custom HTML templates for the most part and rewrite the existing CSS to use the new Drupal built-in elements.

      But, ultimately: yes, everything in this book is going to be basically useless if you want to create a theme for Drupal 7.

      And, in my opinion from using both, if you have the option of Drupal 6 or Drupal 7, go with 7. Quite a few of

  • by Anonymous Coward on Wednesday April 13, 2011 @02:54PM (#35810912)
    Another one to add to the list [slashdot.org]
    • Re: (Score:1, Funny)

      by freefal67 (949117)
      Amen to that. This is getting ridiculous. Only a matter of time before we have more Drupal book reviews than Drupal users.
  • Ru Paul is a tranny, but at least get his name right.

  • Backscratch Review? (Score:3, Interesting)

    by jasnw (1913892) on Wednesday April 13, 2011 @05:10PM (#35812316)

    If this book could cook and iron shirts, I'd marry it!

    Does anyone else think this glowing review sounds like one Drupal developer/bookwriter scratching the back of another in hopes of a similarly-glowing review of their own book? Or perhaps I'm cynical in my old age.

  • Drupal is NOT worthy of 5 or so freaking entries a week. I'm not saying it's good or bad, I'm saying it's not as an important technological subject as it seems to get credit here for. Geeze,

We can predict everything, except the future.

Working...