Preface
This book sets out to explain the workings of the Drupal theme framework, and how you can use it effectively. The goal of this book is to explain basic principles, demonstrate practical solutions to common problems, and create a reference for theming.
The book begins with an overview of the theme system and an explanation of what is included in the default Drupal distro. We next look at how you can squeeze the most out of the default system. The middle chapters discuss PHPTemplate and introduce using themeable functions and manipulating the Drupal style sheets. To illustrate the principles, we take a common theme and modify it. In the final chapters, we delve into creating themes from scratch and more advanced issues, like forms.
For purposes of this text, we focus on the theme engine included in the default distro—PHPTemplate. Similarly, we only touch on creating themes in pure PHP, without the use of a theme engine.
This book is all about controlling the presentation layer of your Drupal site; accordingly, we do not cover creating new modules, or writing custom functionality.
The author of this text comes from a design background and has only basic programming skills. The explanations given, and the rational for many of the choices, reflect the author's background. In that light, this book may not always satisfy hardcore programmers who expect the technical issues to be explained in detail. It should, however, make the life of many designers a little easier and hopefully, with the reference materials we've included, find a lasting home on the shelves of many Drupal developers.
What This Book Covers
Chapter 1 covers the elements of a Drupal theme. It also takes a look at the contents of the Drupal distro and examines the different approaches of the default themes.
Chapter 2 explains how to set up and configure a theme in Drupal. By way of example, we take a default theme and customize it using only the options provided by the system.
Chapter 3 discusses the use of theme engines in general and the PHPTemplate engine in particular. This chapter also lays the groundwork for techniques to modify themes through the system's CSS and themeable functions.
Chapter 4 takes an in-depth look at the system's default style sheets and the various themeable functions.
Chapter 5 explains the process behind intercepting and overriding the Drupal style sheets and themeable functions. This is a key concept for obtaining full control over the presentation layer—without the necessity of modifying the core files.
Chapter 6 provides a hands-on example of the techniques covered in the previous chapters by taking a default theme and then modifying it extensively.
Chapter 7 covers creating a theme from scratch with the PHPTemplate theme engine and also looks at the basics of implementing a theme without a theme engine.
Chapter 8 discusses modifying the look and feel of the many different forms in the Drupal system.
Appendix A is a listing of all the selectors in the various style sheets.
What You Need for This Book
Throughout this book, we will assume that you have the following package installed and available:
Drupal CMS (version 5.x)
Who is This Book for
The main requirements of this book are knowledge of HTML, CSS, and a touch of creativity! Though 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.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
There are three styles for code. Code words in text are shown as follows: "We can include other contexts through the use of the include
directive."
A block of code will be set as follows:
title {color: #666; font-size: 1.8em; line-height: 2.0em; font-style: italic;
When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be made bold:
<div id="block-<?php print $block->module .'-'. $block->delta; ?>"
class="clear-block block block-<?php print $block->module ?>">
<?php if ($block->subject): ?>
<h2><?php print $block->subject ?></h2>
New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "clicking the Next button moves you to the next screen".
Note
Important notes appear in a box like this.
Note
Tips and tricks appear like this.
Reader Feedback
Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply drop an email to <feedback@packtpub.com>
, making sure to mention the book title in the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email <suggest@packtpub.com>
.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer Support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the Example Code for the Book
Visit http://www.packtpub.com/support, and select this book from the list of titles to download any example code or extra resources for this book. The files available for download will then be displayed.
Note
The downloadable files contain instructions on how to use them.
Errata
Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Questions
You can contact us at <questions@packtpub.com>
if you are having a problem with some aspect of the book, and we will do our best to address it.