21 of 21 people found the following review helpful
on 13 December 2008
I am reviewing this as a slow learning learner of Drupal, I'm still a 'Drupal site virgin' let's be clear about that. If you are familiar with Packt titles then the layout, style and presentation of this one will come as no surprise. The book begins with an outline of what is to follow, the conventions used to print code, what is needed to follow the book (Drupal 6!), an invite to provide feedback, errata reports, download code examples piracy concerns and questions.
My upfront conclusion is that this is a good buy. It's not a very technical book, but it is definitely heading in that direction with the content of one or two chapters reminding me of the Pro Drupal volume. This no doubt reflects Shreves' title with the book being well focused as you would expect.
Chapter 1 introduces the elements of a Drupal theme, with much needed instant foot and hand-holds by listing three key concepts (ways to theme) employed through the book:
1. Theming in whole or part
2. Building with blocks
3. Intercept and overrides
These are covered in turn additionally pointing out aspects of Drupal that can confuse beginners, the admin theme and this being the same as the default theme. There's help with explanations of blocks, regions and how these relate to modules.
There's some text on page 11: it does hit the mark, but I think it might be improved with some illustration. That said, buyers of this book are likely to make ready sense of - "The recognized best practice approach to customising themes emphasizes making changes at higher levels, primarily to the theme files themselves." I raise this point as Ric draws attention to (what I understand is) a critical development approach within Drupal that something here deserves promotion as one of book's 'important notes'. A figure of what constitutes Drupal's highest processes and what needs to be left in its original state might make the text clearer. This is difficult for authors, because if readers don't know this then perhaps they need to grasp some fundamentals first? As to which Ric Shreves explains what a theme is; a theme engine; and how all this makes Drupal flexible - with regions being placeholders.
Contrary to the point above overall the book is well illustrated. The way Drupal displays a page is illustrated in five steps. The default themes are listed and shown as screen dumps as with the themes config pages. This for me is not a waste of page real estate. With intercept and overrides briefly mentioned chapter 1 closes by introducing the main theme file types, the notion of sub-themes, PHPTemplate Themes and Pure PHP Themes are also differentiated.
The main theme engines are covered in chapter 3. If you are going to roll your own it is essential you understand the main files, the code and format and how they interact - that is - how they relate to the administration functions. This is detailed, but very accessible contrasting a simple (basic) PHPTemplate theme with a more complex example. A crucial kernel of knowledge for the Drupal themer is the naming conventions used in Drupal. That is, how files names affect the precedence as Drupal searches for the elements that make up a page - the content and styling. Other theme engines are also discussed with links - as per other Packt titles - to additional resources.
Chapter 4 brings us to templates, stylesheets and themable functions and shows how they interoperate. Discussion of the default templates, variables and stylesheets includes advice on disabling CSS compression. There then follows a meaty treatment - a guide no less - of theming elements, such as, theme_box and theme_breadcrumbs p.90. I wish I had come across "Theming the Book Functionality" pp. 95-97 a while back, better late then never. Part of my problem is settling on the content I need for my site. The default book content type is useful. The guide here is very comprehensive running over pp. 90-126.
Chapter 5 tackles intercepts and overrides and begins with overriding the default CSS in the Garland theme, moving swiftly to overriding templates and the themeable functions covered previously. Page 132 has an important note on theme registry and the difference between substituting template and overriding templates p.133. One aspects of many Drupal books is that they can appear repetitious, but for me this actually helps as in Drupal it seems there is frequently more than one way to skin the proverbial cat. An illustration of file naming conventions and precedence helps reinforce previous chapters and the reader's grasp of Drupal. Chapter 5 ends with more on placing function overrides in the template.php file, the use of dedicated template files (with a step by step example); where to place themable functions overrides; how to name them and Overrides in Action. The code examples reveal the difference between default template-block.tpl.php and Garlands equivalent p.140.
Chapter 6 sets out to create a theme by modifying an existing one. As I've been finding, this isn't just a case of your knowledge of Drupal but also having a work environment that suits you. I've an old copy of Dreamweaver (from Studio MX days) and have been looking at Eclipse, PSPad, NetBeans, TextMate, Komodo Edit and other editors and tools. Ric describes Dreamweaver here, so that it can handle theme files, using a server and the use of the popular (Drupal) Devel module. (In true newbie Drupaller style I've tended to install and enable quite a few modules, which can create complexities of their own. Enable them when you need them.)
The Zen theme is then used to create a new sub-theme. The non-trivial matter of planning is stressed. Theme creation by modification is then considered step-by-step: from copying the necessary folder, renaming files, configuring the new theme, to enabling default modules that may be needed to meet a client's brief. Menus leads to links and paths a great source of confusion to new Drupal initiates. Menus need a home so blocks are further discussed with reference to CSS. A very informative twelve pages. A themeable function is overridden, a technical sounding task, but easy to follow in the form of a breadcrumb trail. The final pages of chapter 6 address formatting the blog node. A list of variables is provided comprising 18 items from $context - $zebra and de-mystifies a great deal. Another before and after screen shot completes a really useful chapter.
Chapter 7 explains building a new theme. This is an equally systematic account with illustrations, code and treatment of the essential .info, tpl.php files. There is a top-down perspective too, with page structure explained through page divisions, the placement of links, and key page elements. A final three page code listing and a eight page CSS listing is a pause for breathe. Thischapter ends with a brief review of creating a pure php theme.
I've started to create a couple of themes in Drupal, but chapter 8 is rather advanced for me - I can't (yet) claim to be a Dynamic Themer. If you are intent on fully leveraging the power of Drupal this chapter is essential reading for you. Here Ric shows how to create a unique homepage template, a different template for a group of pages, assign a specific template to a specific page, and designate a specific template for a specific user (power indeed). It's clear how the earlier chapters come in here when dynamically styling blocks. Ric highlights the utility of the Theme Developer feature of the Devel module. I've used this feature, but have yet to question the provenance of a block or other page element. I can see how helpful it will be. Other site components are dynamically styled - comment module, forum, poll and nodes. Throughout the book Shreves acknowledges the '6' in the title: dynamic styling is covered with two pages on $body_classes and a two page listing of the conditions that can be applied, for example; no sidebars. This neatly introduces collapsible sidebars (columns). Template variables crop up again, which may be a bit technical for some beginners but then beginners have to learn...
I have experimented with forms and CCK in Drupal and this is fun because very quickly you appear 'productive'. Chapter 9 explains forms, how they work and the existence of the form API and reference sources. Forms are a more accessible aspect of Drupal to appreciate as you can 'see' the form in the PHP code. As there's no such thing as a free lunch, Ric then reveals five ways to modify Drupal forms. This is done by breaking down the complexity and explaining the dependencies.
Appendix A (described at one point as a chapter) is an informative guide to Drupal stylesheets, in addition to listing the css files, the stylesheets for the default themes are also provided.
Appendix B runs through the desirable contents of a themers' toolkit.
Shreves is aiming for a specific audience with this book - a great help for any publisher. The book may not have much to offer the Pro Drupal expert, but for beginners in theming and intermediate Druapallers there is loads of goodness here. There's also an indication of what's to follow as readers ascend the stairway to Drupal heaven, which is a tantalizing prospect.