Announcing: Slashdot Deals - Explore geek apps, games, gadgets and more. (what is this?)

Thank you!

We are sorry to see you leave - Beta is different and we value the time you took to try it out. Before you decide to go, please take a look at some value-adds for Beta and learn more about it. Thank you for reading Slashdot, and for making the site better!

Book Review: Drupal 6 Theming Cookbook

samzenpus posted more than 3 years ago | from the read-all-about-it dept.

Book Reviews 21

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

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.

Sorry! There are no comments related to the filter you selected.

Drupal 6? (3, Informative)

Slashdot Parent (995749) | more than 3 years ago | (#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? (3, Informative)

Jeremiah Cornelius (137) | more than 3 years ago | (#35810950)

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.

Re:Drupal 6? (0)

Anonymous Coward | more than 3 years ago | (#35810992)

Many still use Drupal 6 because a lot of the modules they want to use are not compatible with Drupal 7 yet. It doesn't make any sense to upgrade if the majority of modules (big or small, they're needed for some reason) will break.

Re:Drupal 6? (1)

Jahf (21968) | more than 3 years ago | (#35811662)

And yet the people just getting into Drupal, which are the people most likely to want a book on the matter, are going to go with Drupal 7 for the most part. This is sort of my predicament ... I did some stuff in Drupal 5 and am getting back into Drupal dev with 7. Had this been a book on 7 I would have jumped at it. But ... its not.

Re:Drupal 6? (1)

KoolyM (602345) | more than 3 years ago | (#35811172)

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 the main changes and slap a Drupal 7 title on the book, the way they did with the Pro Drupal Development book.

Re:Drupal 6? (0)

Anonymous Coward | more than 3 years ago | (#35824954)

This book was released in late 2010. So, I guess that technically, it's the review which is untimely. I'd also like to say enough to all these obviously "paid" reviews.

Re:Drupal 6? (1)

_xeno_ (155264) | more than 3 years ago | (#35811004)

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 the built-in modules make managing content quite a bit easier.

Re:Drupal 6? (0)

Anonymous Coward | more than 3 years ago | (#35815504)

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 the built-in modules make managing content quite a bit easier.

Here's the thing though: there are some major contributed modules that aren't ready for production yet. Übercart comes to mind. Drupal 6 will still be around for a bit.

That said, if you can get away with 7 with the modules you need, do it. And it is awfully late for a Drupal 6 book.

Re:Drupal 6? (0)

Anonymous Coward | more than 3 years ago | (#35811014)

To be honest tho... I'm working on a Drupal 7 site. The main problem isn't Drupal - it's the modules. Not all modules that work with 6 are ported to 7... Not all modules that are quality in 6 are quality in 7. Modules like LDAP and Website Storefronts make or break a site - and without a solid upgrade path in some of these 'ancillary' parts...

Business won't upgrade from IE6, worried about compatibility, old sites, old applications that rely on IE6 "Features"... what makes you think that a widely used product like Drupal 6 won't have an extended life in front of it? Hell... I think there is still a little life left in Drupal 5 sites...

Enough with the Drupal Book Reviews (4, Informative)

Anonymous Coward | more than 3 years ago | (#35810912)

Another one to add to the list [slashdot.org]

Re:Enough with the Drupal Book Reviews (0)

Anonymous Coward | more than 3 years ago | (#35810972)

But "Trevor James" (most like RickJWagner using a psuedonym to attempt to hide his shilling) needs to write another book advertisemen... errr review for Packt Publishing to get his next chec... err so that the Slashdot crowd is informed of the newest Drupal book by Packt.

Re:Enough with the Drupal Book Reviews (0)

Anonymous Coward | more than 3 years ago | (#35813686)

No need, this guy clearly also works for Packt: https://www.packtpub.com/authors/profiles/trevor-james [packtpub.com]

They dont even try and hide the shilling anymore. Slashdot editors should be ashamed.

Re:Enough with the Drupal Book Reviews (1, Funny)

freefal67 (949117) | more than 3 years ago | (#35811468)

Amen to that. This is getting ridiculous. Only a matter of time before we have more Drupal book reviews than Drupal users.

DC mayor detained? interrogated? gassed? (0)

Anonymous Coward | more than 3 years ago | (#35811170)

mayor? arrested? budget? protester (?rebel?)? is this the alternative universe already? are we done exploding ourselves, & being abused? find out on thoughtful thursday, the 4th down glorious day of departure failure, coming up....

Ru Paul (1)

sexconker (1179573) | more than 3 years ago | (#35811226)

Ru Paul is a tranny, but at least get his name right.

Re:Ru Paul (1)

Tablizer (95088) | more than 3 years ago | (#35811694)

When he/she/it gets old and things start sagging...

Drupal is poopal (0)

Anonymous Coward | more than 3 years ago | (#35811794)

Drupal itself is a poop lollipop...

Who cares (0)

Anonymous Coward | more than 3 years ago | (#35811972)

Another Drupal plug. Come on /.

Backscratch Review? (3, Interesting)

jasnw (1913892) | more than 3 years ago | (#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.


euroq (1818100) | more than 3 years ago | (#35814510)

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,

jhk (0)

Anonymous Coward | more than 3 years ago | (#35838030)

Cosplay Wigs [sinomart.com] is an attractive option for people now adays. you can find your friends buy wholesale Cosplay Wigs [sinomart.com] ,your colleagues buy Costumes [sinomart.com] and wholesale Costumes [sinomart.com] .You can see the wholesale Costumes [sinomart.com] , wholesale Cosplay Costumes [sinomart.com] ,is the trend of fashion. Christmas Suits [sinomart.com] , wholesale Christmas Suits [sinomart.com] and all kinds of Maid's Suits [sinomart.com] are appear in our daily life.

Check for New Comments
Slashdot Login

Need an Account?

Forgot your password?