Drupal 6 Theming Cookbook

Drupal 6 Theming Cookbook
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 6%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Take control of the look and feel of your Drupal website
  • Tips and tricks to get the most out of Drupal's theming system
  • Learn how to customize existing themes and create unique themes from scratch
  • Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible

Book Details

Language : English
Paperback : 384 pages [ 235mm x 191mm ]
Release Date : November 2010
ISBN : 1847198686
ISBN 13 : 9781847198686
Author(s) : Karthik Kumar
Topics and Technologies : All Books, CMS and eCommerce, Content Management (CMS), Drupal, Open Source

Table of Contents

Chapter 1: Drupal Theme Basics
Chapter 2: Beyond the Basics
Chapter 3: Custom Themes and Zen
Chapter 4: Templating Basics
Chapter 5: Development and Debugging Tools
Chapter 6: Advanced Templating
Chapter 7: JavaScript in Themes
Chapter 8: Navigation
Chapter 9: Form Design
Chapter 10: Customizing CCK
Chapter 11: Views Theming
Chapter 12: Rapid Layouts with Panels
  • Chapter 1: Drupal Theme Basics
    • Introduction
    • Installing and enabling a theme
    • Uploading a new logo
    • Uploading a new favicon
    • Adding a slogan to the theme
    • Allowing users to choose from multiple themes
    • Displaying a different theme for administration
    • Adding an existing block to the theme
    • Adding a custom block to the theme
    • Displaying a block only on the front page
    • Controlling block visibility based on user role
    • Controlling block visibility based on node type
  • Chapter 2: Beyond the Basics
    • Introduction
    • Understanding the anatomy of a theme
    • Creating a sub-theme based on a core theme
    • Overriding base theme elements in a sub-theme
    • Changing the screenshot image of a theme
    • Including a CSS file in a theme
    • Enabling CSS optimization
    • Creating the mysite module to hold our tweaks
    • Adding a CSS file from a module
    • Displaying a different theme for each day of the week
    • Creating a fresh look using the color module
  • Chapter 3: Custom Themes and Zen
    • Introduction
    • Clearing the theme registry
    • Creating a theme from scratch
    • Creating myzen, a Zen-based theme
    • Choosing a CSS layout for myzen
    • Overriding Zen template files with myzen
    • Adding a custom region to myzen
    • Adding a background image to the theme
    • Adding a conditional stylesheet in Zen
    • Modifying myzen's theme settings
  • Chapter 4: Templating Basics
    • Introduction
    • Changing the layout of a page using page.tpl.php
    • Customizing the appearance of a particular node type
    • Customizing the appearance of a specific node
    • Theming made easy using the Devel module
    • Theme overrides using the Theme developer module
    • Listing all available variables in a template file
    • Displaying the profile name instead of a username
    • Styling the site maintenance page
  • Chapter 5: Development and Debugging Tools
    • Introduction
    • Finding the right function to use to theme an object
    • Analyzing variables using the Devel module
    • Generating sample content using the Devel generate module
    • Resetting the default theme manually
    • Live preview with Web Developer
    • Validating HTML and CSS using Web Developer
    • Turning off JavaScript in the browser
    • Disabling CSS in the browser
    • Inspecting elements and debugging CSS using Firebug
    • Diagnostic logging of JavaScript using Firebug
  • Chapter 6: Advanced Templating
    • Introduction
    • Adding a variable to all node templates
    • Deleting a variable from the page template
    • Adding a custom theme setting
    • Hiding all regions on a page
    • Displaying the last updated date instead of the submitted date
    • Module-based variable manipulation
    • Optimizing using hook_preprocess()
    • Displaying the date field in calendar form
  • Chapter 7: JavaScript in Themes
    • Introduction
    • Including JavaScript files from a theme
    • Including a JavaScript file only for certain pages
    • Giving the username textfield keyboard focus
    • Exporting a variable from PHP to JavaScript
    • Adding default text to the search textfield
    • Displaying comments in compact form
    • Adding column-sort functionality to tables
    • Minimizing and maximizing blocks using JavaScript
  • Chapter 8: Navigation
    • Introduction
    • Adding a menu to our theme
    • Adding content pages to the menu
    • Styling the primary links menu
    • Contextual submenus using the Menu module
    • Adding a drop-down navigation menu
    • Customizing breadcrumbs in Zen-based themes
    • Hiding node links using CSS
    • Styling all external links in a page
    • Styling the Drupal pager
  • Chapter 9: Form Design
    • Introduction
    • Finding the form ID of a form
    • Changing the height of a textarea
    • Turning off the resize feature for textareas
    • Replacing Drupal's textareas with a WYSIWYG HTML editor
    • Reordering fields in a form
    • Replacing a standard submit button with an image button
    • Styling the comment form
    • Using a fieldset to group fields
    • Theming form elements
    • Adding class attributes to form elements
  • Chapter 10: Customizing CCK
    • Introduction
    • Creating a custom node type
    • Hiding fields and labels during display
    • Displaying fields together using field groups
    • Theming CCK content using hook_nodeapi()
    • Theming a CCK field using a template file
    • Adding image support using the ImageField module
    • Using ImageCache to scale and crop images on the fly
    • Adding lightbox support for images
  • Chapter 11: Views Theming
    • Introduction
    • Creating a simple view
    • Styling a node listing using a grid display
    • Merging columns with the Views table style plugin
    • Embedding a view inside a node template
    • Overriding the Views table style plugin
    • Adding a class to a Views style
    • Creating a custom Views style plugin
  • Chapter 12: Rapid Layouts with Panels
    • Introduction
    • Using Panels to create a front-page layout
    • Embedding content in a panel
    • Styling a panel with rounded corners
    • Creating custom styles with the Panel stylizer module
    • Changing the layout of a panel
    • Creating a custom panel layout
    • Replacing the site contact page with a panel
    • Embedding tabbed panels in blocks

Karthik Kumar

Karthik Kumar is a Drupal developer residing in Chennai, India. He first came across Drupal in late 2004 and has been a fan ever since. He maintains a number of modules on http://drupal.org under the moniker Zen – http://drupal.org/user/21209.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 1 submitted: last submission 11 Jun 2013

Errata type: code | Page number: 136 | Errata date: 13 Jan 2011

The console log js code should not end with a }); but with a }


Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Drupal 6 Theming Cookbook +    Microsoft Dynamics AX 2009 Programming: Getting Started =
50% Off
the second eBook
Price for both: $39.00

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Beef up your knowledge of the basics of Drupal theming such as installing and enabling a downloaded theme, changing the logo, and adding a slogan to the theme
  • Customize the look of your website by configuring and extending your existing themes with sub-themes
  • Create custom themes from scratch for websites that demand a fresh look
  • Use the PHPTemplate theming engine to override module output and style it using a theme
  • Style and manipulate the content of your website by adding CSS and JavaScript files via themes and modules
  • Use the ImageCache module to manipulate images on the fly
  • Jazz up the design of your site by incorporating JavaScript elements
  • Make your Drupal site stand out from the crowd by customizing Views via the theme layer
  • Design complex site layouts rapidly with Panels
  • Speed-up development and debugging with Drupal tools such as the Devel module
  • Customize your Drupal site in a creative style by making thorough use of Drupal's APIs


In Detail

Themes are among the most powerful features that can be used to customize a website to fit your needs. The greatest strength of Drupal lies in its design, which, when done right, allows developers to customize every aspect of the site. Although it might sound easy to customize the look of your site, it's not a cakewalk to build custom themes that are easy to administer and maintain.

Drupal 6 Theming Cookbook provides a plethora of recipes that enable Drupal template designers to make full use of Drupal's extensibility and style their site just the way they want it. It is a well-rounded guide, which will allow users looking to theme their Drupal sites to do so by taking full advantage of Drupal's theming system. It covers numerous aspects from creating custom themes to using the powerful CCK, Views, and Panels modules to create rich designs that are easy to administer and maintain.

Structured as a collection of recipes to perform a wide variety of tasks, this book will guide readers through most important aspects of Drupal theming. It starts off with recipes dealing with the basics of Drupal's theme system: you will find recipes for solving all your problems with regions and blocks. It then moves on to advanced topics such as creating a custom theme and using it to modify the layout and style of the content that is output on a page. A substantial number of recipes are dedicated to Drupal's template system, which will provide you with a solid foundation in order to override the output of Drupal and contributed modules. Furthermore, as the combination of modules such as CCK, Views, and Panels is so widely prevalent, chapters have been dedicated for each of these modules. With this book, you'll learn to get the most out of Drupal's templating system and its modules to create rich designs for your site.

A collection of recipes that cover all aspects of customizing and developing unique Drupal themes


Written in cookbook style, this book offers solutions to all common theme design problems through recipes. Each recipe contains step-by-step instructions followed by the analysis of what was done in each task and other useful information. The book is designed so that you can read it chapter by chapter, or you can look at the list of recipes and refer to them in no particular order.

Who this book is for

This book is written for Drupal developers who want to refresh the look and feel of their sites. If you are a Drupal site administrator who is looking to go beyond the basics and customize the presentational aspects of your Drupal site, then this book is for you. It assumes that readers are familiar with rudimentary PHP and acquainted with Drupal installation and general usage. Readers are also expected to have knowledge of CSS and XHTML.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software