Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Drupal 5 Themes
Drupal 5 Themes

Drupal 5 Themes: Create a new theme for your Drupal website with a clean layout and powerful CSS styling

eBook
€8.99 €25.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Drupal 5 Themes

Chapter 1. The Elements of a Drupal Theme

In this chapter, we will introduce themes and their role in the Drupal system. The chapter also covers the various types of themes, the basic elements of a theme, and the functions those elements fulfil. Near the end of the chapter, we will also look at the themes contained in the distro and examine exactly what it is that makes each theme distinct.

The contents of this preliminary chapter provide the general comprehension necessary to grasp the big picture of Drupal. Think of the knowledge communicated in this chapter as a framework from which we will hang the various skills that follow in the subsequent chapters.

What is a Theme?

In the context of Drupal, the term "theme" means a collection of files that are responsible for the look and feel of the website. Other systems use different names for the files that perform the same function in their particular systems—the most common term used elsewhere being "template."

Throughout, we will use "theme" to refer to the collection of files responsible for displaying the information on the page. We will use "template" to refer to certain specific elements of the theme, particularly in relation to the templating engine used in Drupal.

Conceptually, a theme is a visual container that is used to format and display data on the screen. Expressed in terms of its component parts, a theme is a collection of files that format data into the presentation layer viewed by site visitors and system administrators. Expressed in simplest terms: The theme determines how your site looks!

A theme will contain many files that are familiar to web designers, including typically, style sheets, images, and JavaScript. They are also likely to carry some files that may not be so familiar, for example *.theme, or *.tpl.php files. The former is used by pure PHP themes; the latter extension appears in themes that employ the PHPTemplate templating engine bundled with Drupal.

Official Drupal Online Resources

resource

URL

Main Drupal Site

http://www.drupal.org

Drupal Forums

http://drupal.org/forum

Download Extensions

http://drupal.org/project

Drupal Theming Handbook

http://drupal.org/handbook/customization

What is a Theme?


In the context of Drupal, the term "theme" means a collection of files that are responsible for the look and feel of the website. Other systems use different names for the files that perform the same function in their particular systems—the most common term used elsewhere being "template."

Throughout, we will use "theme" to refer to the collection of files responsible for displaying the information on the page. We will use "template" to refer to certain specific elements of the theme, particularly in relation to the templating engine used in Drupal.

Conceptually, a theme is a visual container that is used to format and display data on the screen. Expressed in terms of its component parts, a theme is a collection of files that format data into the presentation layer viewed by site visitors and system administrators. Expressed in simplest terms: The theme determines how your site looks!

A theme will contain many files that are familiar to web designers, including typically, style sheets, images, and JavaScript. They are also likely to carry some files that may not be so familiar, for example *.theme, or *.tpl.php files. The former is used by pure PHP themes; the latter extension appears in themes that employ the PHPTemplate templating engine bundled with Drupal.

Official Drupal Online Resources

resource

URL

Main Drupal Site

http://www.drupal.org

Drupal Forums

http://drupal.org/forum

Download Extensions

http://drupal.org/project

Drupal Theming Handbook

http://drupal.org/handbook/customization

What is a Templating Engine?


A templating engine is a collection of scripts and files that serve to interpret the templating language and process the commands contained therein. As the data is produced from the database queries and from outside sources (if any), the template engine fulfills the function of plugging the data into a pre-determined format for display.

There exist a number of popular templating engines, each of which is designed to interpret different templating languages. Drupal is distributed with the PHPTemplate engine. PHPTemplate is popular for a variety of reasons, not the least of which is that the templating language it interprets is good old PHP—a preferred choice for many Web developers today.

Note

While PHPTemplate is distributed with the Drupal core, there are a variety of other templating engines that can also be installed and used with the Drupal system. Among the most popular are XTemplate, Smarty, and PHPTal. These alternative templating engines can be downloaded from http://drupal.org/project/Theme+engines.

The Range and Flexibility of Drupal Themes


What can be done with a Drupal theme? How much presentation flexibility does the system have? These are key questions that arise when evaluating Drupal for your project. The themes included in the default distro, while useful, don't really offer much in the way of variety. But don't let the default themes prejudice your thinking too much; Drupal can be used to create a wide variety of layout styles, from traditional portal layouts to more cutting edge sites.

When assessing a CMS for flexibility, programmers and designers often look at the issue differently. Programmers tend to focus on the developmental potential the system offers with its range of available theme engines and the use of the popular PHP programming language. Designers, on the other hand, are typically more concerned with determining what restrictions a system imposes on their ability to design the interfaces desired by their clients.

There is good news for both parties. For programmers, the inclusion of the PHPTemplate engine in the Drupal distro means it is possible to tailor the output to match a variety of criteria. The system offers the ability to create custom templates and to specify your modified files over the default files—all without having to actually hack the Drupal core.

For designers, the flexibility of the Drupal approach to site building allows for the creation of attractive and brand-sensitive interfaces (not just a cookie-cutter portal or blog site).

While it may take a while for a new-comer to wade through the Drupal approach to the presentation layer, it is worth the effort, as a little knowledge can go a long way towards allowing you to tailor the system's output to your specific needs.

Who's using Drupal? Some big names…

What You See on the Screen


When you access a Drupal website, what you see on the screen is the result of the site's active theme files. As the theme files call the data, the files also set the styling, position, and placement of the content on your screen. A lot of work for a small group of files…

Within a web page layout, a Drupal theme designer will designate certain general areas to fulfill certain functions. For example, in a typical 3-column theme, the center is used to hold the primary content whereas the two smaller side columns contain secondary information. Screen space within each of those areas is also allocated according to the designer's priorities.

Note

In Drupal, that main content area is often called the content column and those columns on the side are usually called sidebars.

Drupal theme files segregate the elements on the page through the definition of markers called regions. A theme developer can place the regions anywhere on the page by adding a short statement to the code of the appropriate file. Wherever regions have been specified, the site administrator can then assign module output, which in Drupal-speak is called a block.

The default Garland theme, showing hard-coded Regions and sample Block assignments. Note how the Blocks are nested inside specific Regions

Regions are, in other words, placeholders inside the page layout into which a site administrator can position functional output; this is most frequently done by assigning blocks to the region desired.

Regions must be coded into your theme files and are, therefore, primarily the province of the theme developer. Blocks, on the other hand, can be created and manipulated by the site administrator (without having to modify the code).

Blocks can be created in two fashions: First, whenever the site administrator activates a module that produces visual output, a parallel block of the same name automatically becomes active. The administrator can then assign the block to where ever they want the module's output to appear. Alternatively, the administrator can manually create and display a new block from within the blocks manager.

Regions that have no content assigned to them are inactive, but remain eligible for block assignment. Note in the illustration that the regions labeled header, left sidebar, right sidebar, and content all have output assigned to them. Those regions are active. The footer region, in contrast, has no output assigned to it and is inactive on this particular page.

To view the block placement in each of the default templates of your distro, log in to your Drupal site as an administrator and then go to administer>site building>blocks. Click each of the themes' names to view the block placement, which will be overlaid on your screen.

The Big Picture: How Drupal Displays a Page


In order to appreciate fully the philosophy behind theming and the rationale behind the approach to modifying and creating themes that is presented in this text, it is useful to see how Drupal functions at run time.

The shortest explanation of how a CMS functions can be expressed as follows: Text and pointers to other kinds of content are stored in the database; that data is then dynamically retrieved, composed, and presented to a user in response to a request sent from a web browser. Drupal functions in the same manner, with the themes playing the crucial role in the formatting and presentation of the contents.

To illustrate the topic in more detail, consider the following:

The diagram shows a hierarchy, wherein the lowest level is the raw data and the highest level is the final output displayed on the page. The diagram also shows an order of precedence in which the items at the top of the hierarchy, nearest the browser, take precedence over items lower in the order.

By way of further explanation:

  1. 1. The data, for the most part, is stored in basic form in the database of your installation. Formatting, if any, is present only as HTML tags that may have been specified in the content by the author.

  2. 2. The first significant step on the way to output occurs when the Drupal core extracts and pre-processes the data. No real formatting occurs at this level. Any HTML formatting specified in items stored in the DB is simply passed through for interpretation by the browser.

  3. 3. The next step on the way to output sees the templating engine begin to assemble to core and module output into something close to final form.

  4. 4. The final step prior to output occurs when the theme-specific files process the data. This last stage can have a wide range of impacts, from minimal to very significant. The variance in impact depends on the extent to which the theme's author has provided specific directions for the formatting of various items and whether the author has chosen to override the formatting of the templating engine or of the default style sheets in the Drupal distro—all topics we will cover in depth later in this book.

The Importance of Themes in Drupal


The role of themes in the Drupal system relates to the presentation layer of a website, that is, what the site visitors and administrators experience through their browsers. The files in a theme provide HTML formatting, CSS styling, and additional logic that frames the output of the system's functionality. All of these elements come together to create what the site visitor sees in their web browser.

While the default Drupal distro includes a set of themes which will be sufficient for many users, I assume you are reading this book out of a desire to do more, whether it be only to install additional themes and then modify them to suit your needs, or whether you plan to build your own themes from scratch.

In order to grasp better some of the challenges (and opportunities) associated with the Drupal themes, it is useful to look at three key concepts that impact the way you use the system and the way in which you must plan your theme deployment.

Key Concepts

We're going to look next at three key concepts relating to Drupal themes. Those three concepts are:

  1. 1. You Can Theme It All

  2. 2. Build with Blocks

  3. 3. Intercept and Override

You Can Theme It All

One source of confusion for many new users of Drupal is the fact that the default administrator interface is the same as the front-end interface seen by site visitors. Unlike other content management systems, there is not a purpose-built administration interface in Drupal.

During the installation process, the system is configured to display the Garland template for both the front end and the back end. This is yet another example of the high level of integration typical to Drupal. If you want to work with one consistent template throughout, you can.

The seamless integration of the administrator interface into the site works well in some cases, but in others it may be problematic. There will be situations where the use of the same theme for the visitors and the administrators is undesirable, for example, on a marketing-oriented site where the artistic theme used for the site visitors may be impractical for site administrators.

The system's default use of the same page template for both the front end and the back end conceals the existence of a great deal of flexibility and makes it non-obvious that you can do more with the themes. That's the bad news. The good news is that you can do more—much more!

The Drupal system allows you to specify different page templates for different purposes on your site. You can, for example, build one page template for your home page, another for your interior pages, and yet another for your administrator's use. The sky is the limit on this point as the templating engine also gives you the ability to provide a variety of styling for very specific types of contents or for the output of a particular module. The control is highly granular and with a little practice (and a little ingenuity) you will find the system to be very flexible indeed.

In the following chapters, we will look at how to implement multiple themes and how to theme and configure all the various constituent parts of the Drupal system. You can theme it all!

Build with Blocks

As noted earlier in this chapter, the code of a Drupal theme includes placeholders called regions. The regions are areas in a page where content will be displayed. The site administrator can then assign a variety of output to the regions through the admin interface.

One of the most common sources of output is the Drupal modules. Modules are stand-alone bits of code—mini applications in some cases—that extend the functionality of your site. The default distro includes a large number of modules. It is through modules that Drupal provides functions like the Forum, the Aggregator and even additional administrative power, like the Throttle module.

Some modules produce output that appears on the screen, for example, the Forum module produces a threaded discussions functionality with extensive output. Other modules simply add functionality, for example the Ping module, which notifies other sites when your content has changed. The administrator is able to toggle modules on or off and able to assign the output of those modules—called blocks—to the various regions in the theme.

The process of activating modules and assigning blocks to regions on the pages is one of the most basic and most important skills for a site administrator. Understanding how to administer the system and what options are available is key to building interesting and usable sites. A great deal of flexibility can be squeezed out of the system in this area alone.

This system, however, is not without complications. Module developers typically build their modules to be self-contained units. This independence also extends to the presentation layer of these discreet items of code. As a result, almost all the modules have distinct formatting and specific files that control that formatting. This approach to programming and modularization leads to a system in which a significant number of discrete units must be dealt with, adding greatly to the potential for complexity in changing the look and feel of a site to your specifications.

The list of default modules available in Drupal

Each of the functional units above—each module—is kept in a separate directory inside the Modulesfolder. Many contain their own CSS files, creating a large number of style sheets scattered throughout the system. Add to that already daunting collection of modules any additional extensions you wish to install on your particular site and you can see how CSS juggling might come to dominate your life. Nevertheless, fear not, as styling all of this is manageable, using the technique discussed below.

In addition to the blocks produced by modules, you can also create blocks specific to your installation. Manually created blocks provide an easy avenue for placement of additional information (e.g., text or images), or, by inclusion of PHP code in the block, additional functionality.

Each of the blocks in the system, whether created by modules or manually created by the system administrator, can be themed individually, if you so desire.

Intercept and Override

The process of getting data from its raw form to its final displayed form provides several opportunities for you to affect the output prior to the data's arrival on the viewer's screen. While it is possible to work at the lower levels—hacking the core or the modules or the templating engine—I advise against that. The recognized best practice approach to customizing themes emphasizes making changes at the higher levels, primarily to the theme files themselves.

The best practice approach to customizing themes involves intercepting and overriding files and styles—not altering the core. In short, if you wish to style a particular block, instead of hacking the module that produces it, you will override the default module file with one of your own, or you will intercept the styles or functions of the module with your own; most likely, you will use a combination of both those techniques. The new files and styles you create will be part of the theme itself.

By choosing to affect the system's output at the highest levels of Drupal's processes, we leave the core in a purer state. This approach has several advantages, the most significant being that system upgrades and patches can be applied without fear of losing modifications necessary to your presentation. Sites customized in this manner are easier to maintain and your code remains portable and available for re-use in other deployments.

Note

"override"—as used in this context, refers to creating a file, function, or style which is redundant with an existing file, function, or style and, courtesy of the order of precedence inherent in Drupal, the new file, function, or style will control.

The Contents of the Drupal Distro


The default distribution of Drupal comes with a variety of themes ready for use. The themes provide a basic variety in look and style and also serve an important didactic purpose, that is, helping those new to Drupal understand how themes work. By studying the themes in the distro, you can learn from functional examples how various theming techniques can be implemented successfully.

To view the various themes, login as an administrator, then go to administer>themes. This is the theme administration page and on this page you will see a list of the themes installed and the controls that allow you to enable, activate, and configure each of the themes.

There are six themes in the default distro:

  • Bluemarine

  • Chameleon

  • Garland

  • Marvin

  • Minnelli

  • Pushbutton.

The templates provide some variety in layout, options, colors, and accessibility. Four of the themes employ the PHPTemplate engine; two do not. The default theme which is automatically selected during the installation process is Garland. You can switch to any of the other templates easily from within the administration interface.

To change templates, simply access administrator>themes in the admin interface and click the Enabled checkbox next to the theme you wish to activate. Select the radio button control marked Default if you wish to set the theme as the default. (The default theme will appear on all pages, which are not specifically assigned to another theme.) The new theme will automatically appear once your choice has been saved.

The admin screen showing the controls for enabling and configuring themes

All six templates contained in the distro can support either two or three column layouts, though in the default configuration you will see only two columns. The way in which these themes are designed creates the flexibility in the layout. The site administrator can assign items to a third column if desired; the third column will only appear when items are assigned to that position. When items are not assigned to the third column, the theme automatically collapses the unused region to show only two columns. The assignment of items to those columns is discussed in the next chapter.

The themes also vary in their approach to accessibility issues. Pushbutton and Bluemarine both employ tables in their layout. The other templates depend entirely upon CSS to place and control the elements on the page. (Table-based layouts are generally not preferred due to the barriers they erect to achieving accessible web pages.)

Note that two of the Themes, Minnelli and Marvin, are actually simple variations on other themes (specifically, Garland and Chameleon, respectively). The derivative

themes are built on the same frameworks as their parents (note the visual similarity in the accompanying illustration), but employ different style sheets and use CSS to impart a different layout and a slightly different look. The presence of a dedicated style.css file in a subdirectory tells PHPTemplate to treat this as a separate theme, distinct from its parent.

The Theme Files


The themes and their respective files are kept in the directory named themes on your server. The default distro also comes bundled with the PHPTemplate engine. The PHPTemplate files are located in a sub-directory inside the themes directory on your server.

To view the theme and template engine files in your Drupal installation, access your server and navigate to the directory located at /themes.

Screenshot of section of the default Drupal directory structure on a server

The sample templates included in the distro demonstrate the two principal methods of creating themes. The themes Bluemarine, Garland, Minnelli, and Pushbutton all employ the PHPTemplate engine. The themes Chameleon and Marvin are built without use of PHPTemplate. Both Chameleon and Marvin are written directly in PHP; themes that use this approach are sometimes referred to as "Pure" PHP themes.

Which approach is better for you? Hard to say; the answer will vary from person to person and according to your intended use. The right answer will depend largely on your needs and your relative skill with the technologies. (Building a pure PHP theme can be a challenge for those who lack strong PHP skills!) Speaking generally, the PHPTemplate approach is preferable as it is not only easier to master, but it is also more modular and reusable than a pure PHP approach to themes.

The Files of a PHPTemplate Theme

Let's look at the files that comprise the Bluemarine theme and their roles at run time:

  • block.tpl.php Defines the appearance of the blocks on the page.

  • box.tpl.php Defines a specific format—a box used to frame things (like comments in the Bluemarine theme).

  • comment.tpl.php Defines the appearance of the comments which follow items.

  • logo.png An image file containing the logo used in the theme.

  • node.tpl.php Defines the appearance of the nodes.

  • page.tpl.php This is the primary theme file. This is the only required file in a PHPTemplate theme and typically defines the appearance of most of the page.

  • screenshot.png An image file containing a screenshot of the theme; this is used as a reference.

  • style.css The style sheet for this theme.

Note that not all of these files are necessary for a PHPTemplate theme to function properly. The two key files are page.tpl.php and style.css.

Note

While it is not necessary for the theme to function, it is best practice to always include screenshot.png, as this file is used in the admin interface to provide site administrators with a preview of the installed themes.

The file page.tpl.php does the heavy lifting in all PHPTemplate themes. This file is the only required file and it handles most of the styling as well as incorporating by reference any theme-specific overrides contained in related files. In the case of the Bluemarine theme, those additional overrides are:

  • block.tpl.php

  • box.tpl.php

  • comment.tpl.php

  • node.tpl.php

Overrides are not required—the overrides in the Bluemarine theme represent a decision made by the author of the theme to style specific elements. As this is within the discretion of the theme developer, the presence and extent of overrides will vary from theme to theme.

The PHPTemplate-specific files all follow the same naming convention *.tpl.php. The prefix of each of those files is specific in that they are intended to override functions defined elsewhere. For the system to recognize that these files in the theme directory are intended to override the originals, the names must be consistent with the originals. The naming of some of the other theme files is flexible and within the discretion of the author.

We will take an in depth look at the various PHPTemplate files and the concepts and rules relating to overrides in later chapters.

The Files of a Pure PHP Theme

Let's look at the files that comprise the Chameleon theme and their roles at run time.

  • background.png An image file used as this theme's background.

  • chameleon.theme This is the primary theme file. This is the only required file in a pure PHP theme and it defines the appearance of the page.

  • common.css The style sheet for this theme.

  • logo.png An image file containing the logo used in the theme.

In this theme, the key pair of files is chameleon.theme and common.css. The *.theme file uses PHP to style page elements by overriding the default theme functions created by the system. The *.css contains the styles necessary to support the presentation.

We will take a more in depth look at pure PHP themes in later chapters.

Summary


This chapter lays the groundwork for what comes ahead. You should now have some familiarity with the big picture—with the basic terminology used in Drupal, with the way Drupal presents data at runtime, with the general functions of themes, templating engines and style sheets, and with the location and nature of the key files and directories.

You should also be aware that despite the apparent complexity one sees at first glance, that Drupal themes can be managed in a logical and relatively easy fashion by applying a strategy of intercepting and overriding the theme files.

Left arrow icon Right arrow icon

Key benefits

  • Learn to create new Drupal 5 Themes
  • No experience of Drupal 5 theming required
  • Set up and configure themes
  • Understand Drupal 5's themeable functions

Description

Drupal is an award winning open source Content Management System. Based on PHP/MySQL, its power and flexibility combined with its exceptional design mean it is already on the way to becoming the de facto standard for CMS Websites. Drupal?¢‚Ǩ‚Ñ¢s modular design and structured source code make it both highly flexible and easily extended and modified. Drupal is extremely scalable, making it ideal for both a simple personal website as well as an industrial strength commercial or institutional web presence.Drupal is a model open source project in that it has a large, friendly community of people who contribute to the project in various ways. Drupal is not only free and easy to use, but this community provides on going mutual support.

Who is this book for?

This book is the ideal introduction to theming with Drupal 5. If you want to create a striking new look for your Drupal website, this book is for you. Starting from the basics of theme setup and configuration, you will learn about the Drupal theming architecture and the PHPTemplate engine, and then move on to modifying existing themes and building new themes from scratch. Included is a complete guide to the various style sheets and themeable functions in Drupal 5, making this book a valuable resource even to experienced theme developers. It covers: Creating custom templates Basics of theming in pure PHP Modifying an existing PHPTemplate theme' a step-by-step guide Creating a new PHPTemplate theme' a step-by-step guide Working with forms The main requirements to make use of this book are knowledge of HTML, CSS, and a touch of creativity! Although this book aims to make Drupal theming accessible to designers, theming in Drupal 5 involves writing some PHP code, and a basic knowledge of PHP will be helpful.

What you will learn

  • This book is the ideal introduction to theming with Drupal 5. If you want to create a striking new look for your Drupal website, this book is for you. Starting from the basics of theme setup and configuration, you will learn about the Drupal theming architecture and the PHPTemplate engine, and then move on to modifying existing themes and building new themes from scratch. Included is a complete guide to the various style sheets and themeable functions in Drupal 5, making this book a valuable resource even to experienced theme developers. It covers:
  • Creating custom templates
  • Basics of theming in pure PHP
  • Modifying an existing PHPTemplate theme?¢‚Ǩ‚Äù a step-by-step guide
  • Creating a new PHPTemplate theme?¢‚Ǩ‚Äùa step-by-step guide
  • Working with forms
  • The main requirements to make use of this book are knowledge of HTML, CSS, and a touch of creativity! Although this book aims to make Drupal theming accessible to designers, theming in Drupal 5 involves writing some PHP code, and a basic knowledge of PHP will be helpful.
Estimated delivery fee Deliver to Romania

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 31, 2007
Length: 260 pages
Edition : 1st
Language : English
ISBN-13 : 9781847191823
Languages :
Concepts :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Romania

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Publication date : Dec 31, 2007
Length: 260 pages
Edition : 1st
Language : English
ISBN-13 : 9781847191823
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 108.97
Drupal 5 Themes
€32.99
Drupal 6 Theming Cookbook
€37.99
Drupal 7 Social Networking
€37.99
Total 108.97 Stars icon
Banner background image

Table of Contents

8 Chapters
The Elements of a Drupal Theme Chevron down icon Chevron up icon
Theme Set Up and Configuration Chevron down icon Chevron up icon
Working with Theme Engines Chevron down icon Chevron up icon
Style Sheets and Themeable Functions Chevron down icon Chevron up icon
Intercepts and Overrides Chevron down icon Chevron up icon
Modifying an Existing Theme Chevron down icon Chevron up icon
Building a New Theme Chevron down icon Chevron up icon
Dealing with Forms Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(12 Ratings)
5 star 33.3%
4 star 50%
3 star 16.7%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




E. Langhout May 05, 2008
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book for web-designers/developers who start with Drupal 6 Themes. Can't wait for the Drupal 6 version or a book that addresses the more experienced Drupal Developers.
Amazon Verified review Amazon
Alan Doucette Jan 20, 2008
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you are a designer wanting to learn Drupal, this book is for you. It is written by a designer so there are no programming sections full of code. It shows you how you can customize Drupal's HTML and CSS in detail. The book has a good amount of screen shots, charts, and other visual aids that really help the right side of the brain.The first 2 chapters are great setup chapters, so if you are new to Drupal they help you get started by telling many of the things designers need to know. There were several "ah ha" moments where concepts finally clicked because of the author's descriptions and examples.This is also a great reference book. It lists all the CSS files and theme functions that come in Drupal core with a short sentence on their content or purpose. There is an appendix that charts out all the Drupal core CSS files giving you a visual lookup of all ID's and classes for each CSS file.As I am not new to Drupal the organization was a little strange at first. Topics like overriding template files is covered a few times in first half with little detail. But after finishing the book the organization is more clear. The author spends time going over all the areas of Drupal theming to give you a good background then spends a few chapters modding an existing template and creating one from scratch where he goes into more detail.The last chapter covers Drupal forms which could do with a book of their own almost. But the author covered a lot of good material to get you started."Drupal 5 Theming" doesn't cover CCK or Views theming. CCK and Views are contributed modules that almost every Drupal 5 site uses. It also doesn't cover any advanced theming topics. Which makes this book GREAT for the Druapl beginner, GOOD for intermediates, and FAIR for advanced themers.Also with Drupal 6 almost here, if you are worried this book will be out of date, don't. There are several theming advances in D6 but the background and understanding this book gives you still applies. Plus D5 is here for the foreseeable future so if you are working on a project now, it will make your job a lot easier.
Amazon Verified review Amazon
Sun Moon Stars Feb 28, 2008
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm extremely impressed with Drupal 5 Themes. I received this book just after finishing coding three custom themes for clients - so Drupal themeing was definitely on my brain! The book is written for non-technical designers, not programmers. However, experienced programmers could find real value in this book - particularly if the programmers are new to Drupal. This book has some of the clearest, easiest to understand explanations of Drupal. If you spent much time reading the Drupal documentation, you will really appreciate the author's writing style. I'll be teaching Drupal soon, and I'm considering using this book as part of the course.I like the structure of the book. After providing an excellent overview of Drupal, the first major exercise is modifying an existing Drupal theme. That is how most people start off learning how to theme anyway, but with this guide they should have a much better idea of what they are doing than most beginning theme designers. The second major assignment is for the programmer to design a theme from scratch. After completing both of these assignments, the reader should have tremendous confidence that they will be able to design a theme.I wish the author had written about CCK and views moduales. They are important to many sites, and his writing style would have been a welcome addition to the documentation.
Amazon Verified review Amazon
Bruce Kersten (bruce@savantcreative.com) Jun 19, 2008
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is exactly what I have been looking for. Being pretty new to Drupal I had been using the documentation at the Drupal site. It is good for starting off but my company, Savant Creative Group - [...] - needs to develop our own themes. The book is well written, well documented and not too heavy on PHP. It is great for design people who know html and css.
Amazon Verified review Amazon
R. Hill Mar 14, 2008
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
A first release candidate of Drupal 6 was made available on December 20 of 2007, that is, 2 days prior to the publication of this theming guide, which covers Drupal 5. Drupal 6.1 has since been released, and many of Drupal's most popular add-on modules are now ready for use on production web sites. The author mentioned on his blog that an updated version of his book will be published, but Packt Publishing is not yet listing 'Drupal 6 Themes' among its upcoming publications. Still, I read the book, and worked through its examples on a Drupal 6 install. As a somewhat seasoned Drupal developer, I still found the book helpful. I highly recommend it, provided that as you read along you refer yourself to the concise (and well-put-together) Drupal 6 theming guide available on Drupal.org. Theming has definitely taken a leap forward in D6. For instance, intercepting and overriding theming functions is a lot easier now.What this book covers:Chapter 1 ("The Elements of a Drupal Theme") presents the theming terminology used in Drupal, and that hasn't changed in Drupal 6.Chapter 2 explains how to set up and configure a theme in Drupal through the admin interface. By way of example, we download the theme Gagarin from Drupal.org and install it. We also configure 'Garland', which still is the default theme shipped with Drupal. Surprisingly, I learnt quite a handful of tricks in this chapter. All of it is applicable to Drupal 6; even the neat PHP snippets used for the content & visibility of custom 'blocks' work as is. For fun, I ported the Gagarin theme to Drupal 6 in less than 10 minutes, using a porting guide put together by Wesley Tanaka. Your milage may vary (you may do it faster than I).Chapter 3 explains how the PHPTemplate 'engine' works. Wordy as it is, the definition of a theming engine remains somewhat ambiguous. You may download this chapter from the publisher's web site. Take note that the default PHPTemplate 'template' files have been moved to their respective core module folder in Drupal 6. For example, you'll find the default page.tpl.php file under /modules/system, and node.tpl.php under modules/node.Chapter 4 is a reference guide to stylesheets and themable (ie:overridable) functions. Only a brief description (ie: one sentence) is provided for each function. The author gives us a snippet of PHP code that produces a list of the theming functions used on the page, but it's somewhat useless because with it we don't know which function produces what markup. In Drupal 6, a neat & "sexy" add-on module, part of the 'Devel' kit of modules, tells us which function to override (and so much more): by Firebug-style point-and-click, we select the DOM element we wish to theme, and we learn how to do so through a 'tool tip'.Chapter 5 presents different ways to intercept & override themable functions. In Drupal 6, one of these ways has been simplified, that of "placing overrides in dedicated [template] files" for which no default file exists. One no longer needs to tell the theming engine about the presence of the template file, as we used to inside template.php. In the instance where we want additional variables to become available inside the template, we use the new Drupal 6 function themeEngineName_preprocess_hook.In Drupal 6, adding stylesheets (besides the default style.css) is as easy as adding a few lines in a new 'info' file for the theme. Same with creating new regions on the page : the theme.info file takes care of that. (For these, one needs not add any PHP code to template.php.)In chapter 6, we modify a theme, 'Zen'. Be warned : even the drupal-5 version of this theme has undergone significant change since the publication of the book.In chapter 7, we learn how to create a theme from scratch -- and so much more (this chapter definitely should have been broken down). We're finally presented with a list of the variables available in each template file. In Drupal 6, many variables have been renamed (for example, $sidebar_left has become... $left), and new handy ones have been created which are available in all templates, for exampe $logged_in and $is_admin. Note that we should use the new D6 variable $body classes to apply dynamic CSS styling, instead of the ol' $layout (still available).In chapter 8, we learn how to theme forms. I had to do some research to find how to apply the author's solutions within Drupal 6. Some change is trivial, for example the handy hook_ form_alter function has different parameters passed to it in D6, and one only needs to change the function's 'prototype', ie:From that in D5 : function modName_form_alter($form_id, &$form){To this in D6 : function modName_form_alter(&$form, $form_state, $form_id){In D6, some form-theming solutions are easier to implement... or more difficult: I still haven't figured how to use images for the forms submit button. However, imo, a CSS solution is preferred in Drupal 5 _and_ 6.What this book does not cover, and I wish it did:- How to use jquery, the wondrous javascript library shipped with Drupal (there is no mention of it, really).- How to produce a theme with a configurable color scheme, using the Color Module. A simple tutorial where we create a theme for which we can change the color of the header and/or links through the 'setttings' UI would have been awesome.- Related to the last point, we're not shown how to modify the theme's settings page - to add to it.- How to theme 'Views' pages, and nodes created with the Content Construction Kit (CCK).- How to commit a theme to Drupal.org CVS (using a freeware utility like TortoiseCVS, for example).This book is particulary successful at breaking down information into bits and steps. It's extremely well-written, quite technical and in-depth, and provides a handful of screen captures in most places. We can theme it _all_ in Drupal, and the author drives that point home.Where the book somewhat falls short in its delivery:- Although the author comes from a 'design background' (so it says in the book's preface), he fails to inspire. The theme created from srcatch is particularly unappealing.- When it comes to designing Drupal themes, we're faced with basically copying and pasting CSS rules scattered throughout a set of *.txt source files to one stylesheet.To be fair, this is not a book on CSS, nor web design.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela