Drupal 6 Themes
1 comment | Posted: 25 May 09 in Books, by Yannick Lyn Fatt
Over the past year and a half I’ve been doing quite a bit of work with Drupal, a free and open source Content Management System (CMS). Whenever I’m asked how I’m finding Drupal, my answer is usually that, “I have a love hate relationship with it.” There is no doubt that Drupal is a very powerful and flexible CMS and more and more companies, universities, communities and individuals are using it. If you don’t believe me just look through the various Case Studies and also the list of Drupal sites posted by Drupal’s creator and project lead, Dries Buytaert. Most of my frustrations came from the fact that I’m used to having complete control over the markup behind the sites I build. At first I found this not to be the case with Drupal, but as I began to work more and more with it and learn the ins and outs, I started to see how to regain that control.
Enter Drupal 6 Themes by Ric Shreves. This book opened my eyes to some things that I didn’t know or understand about theming Drupal. While this book is geared towards Drupal 6, there were quite a few things I was able to learn and apply to Drupal 5 which is the version of Drupal that we are currently using at work (The other option of course would be to buy Drupal 5 themes by the same Author and Publisher). As the book rightly says “Drupal 6 Themes is an ideal introduction to theming with Drupal 6.”
The 1st few chapters (1-3) discuss the basics of Drupal theming. I felt these chapters weren’t really for me since I was already familiar with the basics. However, it will be very good for person’s not familiar with Drupal theming at all. It describes what a theme is, how to add new themes and how to configure those themes. Theme engines are also discussed. Drupal is capable of using a variety of theming engines to build sites, such as Smarty, PHPTal and XTemplate. However, Drupal is distributed with PHPTemplate which relies on good old PHP and which many PHP developers are already familiar with.
Chapters 4-5 then delve into template files, themable functions and how to intercept and override them. This is where you begin to regain control over the markup output by Drupal and it’s modules and are able to customize it the way you want it. One of the nice things about Drupal is that there are certain themable functions in the core and in contributed modules that follow a naming convention (ie. ‘theme_function_name’), which makes it easy for you to identify and override the functionality and output from it’s original format. The principles of naming conventions applies to overriding templates as well. For instance one of the template files that is essential to every Drupal theme is the page.tpl.php file. This controls the general layout of the site and does most of the heavy lifting. You could for instance override this and have a different look for your user pages by simply creating a new file called page-user.tpl.php and making adjustments as necessary. You can do a whole lot more, but I’ll let you read the book to find out all the juicy details.
Chapter 6, shows you to modify an existing theme, the Zen theme, which prides itself on being flexible and one of the better themes to start with when learning how to create themes in Drupal. Chapters 7-8 continue to build upon and tie everything together. Ric shows you how to create a theme from scratch and have multiple page templates. You will also learn how to control how your theme is displayed based on the type of content, the user viewing it and other factors. Lastly, chapter 9 demonstrates how to theme the various forms generated by the Drupal core. A form I found myself wanting to customize recently was the User Login Block, luckily for me, this was covered in the book and I learnt the different approaches to modifying this and other forms within Drupal.
With all that said, if you’re new to theming in Drupal, I definitely recommend this book. Ric did a good job of giving a solid foundation and covering most of what you need to know to comfortably create themes in Drupal.
Discuss This Topic
Comments closed after 2 weeks.