Drupal 5 Themes
Michael J. Ross writes "For any Web site based upon Drupal, an increasingly popular CMS, the styling of the site is controlled by whatever Drupal "theme" has been installed, enabled, and chosen, by the site administrator. Out of the box, Drupal offers only a handful of themes, and thus site administrators oftentimes will instead opt for a theme developed by a third-party. However, if the administrator cannot find one that exactly matches their needs or those of their client, then they will either have to pay someone to custom-build a theme, or learn how to do it themselves. Fortunately, creating a new theme or modifying an existing one, is not that difficult, as demonstrated in Drupal 5 Themes, by Ric Shreves." Read below for the rest of Michael's review.
Drupal 5 Themes
author
Ric Shreves
pages
260
publisher
Packt Publishing
rating
6/10
reviewer
Michael J. Ross
ISBN
1847191827
summary
A guide to modifying Drupal themes, and creating new ones.
The book was published on 22 December 2007, by Packt Publishing, under the ISBNs 1847191827 and 978-1847191823. It is a slender volume, at only 260 pages, and yet covers most of the basics, in eight chapters and one appendix: the basic elements of a Drupal theme, including the files involved; finding, installing, configuring, managing, and uninstalling themes; theme engines, with a focus upon the most commonly used one, PHPTemplate; style sheets and themeable functions; overriding CSS rules, Drupal functions, and template files; modifying an existing theme, using the popular Zen theme as an example; creating a new PHPTemplate-based theme from scratch, and how to extend it; creating a theme not based upon an engine; theming Drupal forms. On the book's Web page, visitors can download most of the sample code presented in the book, send the publisher feedback, ask the publisher a question, and download a sample chapter (number 3, "Working with Theme Engines") as a PDF file.
On the positive side of the ledger, Drupal 5 Themes is a solid introduction to Drupal theming, and the author takes his time in explaining the key concepts. Extensive use is made of sample code, in addition to screenshots of themed pages, admin pages, directory trees, and more.
On the negative side of the ledger, the book contains many small errors — even for a first edition. There are far too many misspellings: "new-comer" (page 8), "where ever" (page 10), "blocks manager" (on the same page — even the same paragraph!), "in depth" (as an adjective, on pages 23 and 24), "jump start," "down side" (both on page 27), "sites" (as a possessive, page 54), "some where" (page 87), and one that undermines the technical credibility of the author, "FavIcon" (page 50). Sadly, there are numerous other errata. For instance, on page 47, we stumble over "to the tailoring an existing theme." On page 10, "assemble to core" should instead read "assemble the core." In several instances, "comprise" is mistaken for "compose." The alert reader will spot other signs of sloppy editing: One pages 18-19, the author should have chosen either "Tables Free" or "CSS-based," and be consistent. The penultimate paragraph on page 123 has double periods. The synonym of "theme" that is posited, "template," is related, but not synonymous; but the common term "skin" isn't even mentioned. On page 188, "page-blog-tpl.php" contains a typo.
Some of the author's phrasing is quite awkward, e.g., "Dev Server" (page 120) apparently means a local Web server. In fact, throughout the book he flip-flops on using lowercase or title case for such terms as "block" and "region." The overuse of title case is also found throughout the book, with some of it almost laughable, e.g., "... the Big Picture." In terms of the writing style, it could certainly be improved, such as judicious use of commas where needed — particularly in the countless run-on sentences. In general, this book contains more errata and style gaffes than any other computer book I have ever seen, on an absolute basis — even worse per page, considering it has perhaps half the number of pages of the typical computer book.
Turning to the technical material itself, there are inconsistencies as well. For instance, some URLs contain root directory slashes, while others do not. Some menu breadcrumbs use ">" as a delimiter, while others use "|." Furthermore, the Drupal menu breadcrumbs (e.g., "administer>themes") should be in sentence case, not lowercase, to match Drupal's names. Fortunately, none of the aforementioned flaws prevent the reader from understanding the book's material, but they reveal insufficient effort in the writing and editing phases, and suggest that other, less obvious, mistakes were possibly made.
In terms of the book's production, it could be improved. Some of the images are highly pixelated — especially the screenshots of directory trees. What will perhaps be most annoying to some readers, is the publisher's use of a glossy black ink that causes each page to reflect one's reading light. One might initially hope that this is an unavoidable disadvantage of the publisher perhaps choosing an environmentally friendly ink, or some similar reason, but nowhere in the book is the type or choice of ink mentioned. This suggests the poor choice was made for economic and not ecologic reasons.
The chapter summaries add nothing to the discussion, and could be removed without loss.
We now turn to specific chapters. In Chapter 2, the author discusses how to install and configure themes, and also touches upon global configuration settings, as well as module and block management. This information is put to use in the second part of the chapter, which covers the customization of Garland, the default Drupal theme. Some of the material in this chapter could prove puzzling or even misleading to many readers. The author states that enabling a theme and setting it as the default, applies it to "both front end and back end of the site" (page 31). Actually, it only changes the front-end theme; the back-end theme is set via Administer > Site configuration > Administration theme; oddly, he actually acknowledges this much later. In the theme configuration screenshots in Chapter 2, the "gagarin" theme is missing, even though it was supposedly installed earlier. On page 40, the author instructs, "To access all the user permissions and configuration screens in one place, view your administrator console by module." But Administer > Site building > Modules is not where the administrator sets user permissions and blog configurations. In the discussion of page specific visibility settings, the third radio button option (entering PHP code to control the visibility of the block) is only displayed if the user has enabled "use PHP for block visibility" in Administer > User management > Access control. The figure caption on page 50 could give a reader the mistaken idea that Drupal renames the custom logo image to "garland_logo.gif" automatically, prior to the configuration settings being saved, which is mentioned afterwards. On page 58, the illustration shows PHP code that appears to contain an extraneous tag, , which is probably a holdover from the illustration on page 56; in fact, it breaks the code, because the presence of that string always effectively returns TRUE. On pages 86 and 87, the PHP code contains four back ticks, which should be replaced with straight apostrophes.
Theme engines, specifically PHPTemplate, is explored in Chapter 3. The author explains the primary functionality of the six files that constitute this built-in theme engine. These are illustrated by comparing two PHPTemplate themes — Garland versus Gagarin. The chapter concludes with brief overviews of three other theme engines, PHPTAL, Smarty, and PHP XTemplate.
Modifying a theme to customize a Drupal site, can be done in one of two ways, or a combination of the two, which is the typical approach: overriding default CSS rules, and overriding themeable functions. Chapters 4 and 5 explain how to do so, with the former containing a list of themeable functions organized by functionality. Chapter 5 covers the details of overriding Drupal CSS and functions, including a valuable discussion of the various options open to the developer for overriding functions, including step-by-step instructions. The chapter concludes with a brief explanation as to how to intercept template files.
Chapters 6 and 7 form the heart of the book, because they explain the details of modifying an existing theme and building a new one from scratch. Anyone interested in learning how to style their Drupal-based Web site with maximum flexibility, will find these two chapters of value. However, there are several pitfalls the reader will want to watch for: Early in Chapter 6, the author instructs the reader who is following along to rename the theme-specific functions in the template.php file from "zen_" to "tao_." Yet this is insufficient, because the page formatting for this new theme, tao, already differs from Zen's. This is likely due to the theme PHP files not finding one or more CSS files that still contain the name "zen." In fact, to completely replace the old theme name throughout Zen's code, one needs to change nine other PHP files. In the section describing how to set up the menus, the weights for the "Home" and "Contact Us" links are supposedly set to 10 and -10, respectively, which would place the former to the left of the latter; yet the illustration on page 148 shows the opposite. The "Blog Entries" weight should be -10 instead of 10. The weights for the footer navigation menu links appear to be equally messed up. In addition, both instances of "yourdomain" is followed by an erroneous space. Frankly, it is as if the book had never been technically edited.
Chapter 7, the longest in the book, is possibly the one that will receive the most study by readers who wish to learn the intricacies of making their own theme from the ground up. The author provides a step-by-step explanation as to what is involved in creating a new theme, and the advantages and disadvantages to alternative approaches. He uses a sample theme, "Bluewater," to illustrate the ideas. The problems with this material are fairly minor: The diagram caption on page 152 states that the elements within the CSS are ordered alphabetically, and yet no alphabetical ordering is apparent. In fact, the ordering doesn't even match that in the page.tpl.php file. In addition, page.tpl.php contains a couple curly quotes, though this does not affect its functionality. Aside from these issues, the discussion is quite thorough, and the reader ends up with a fully functional — though not especially attractive — Drupal theme. The chapter concludes with coverage of template variables, the use of multiple templates, dynamic theming, and developing a theme without the use of any theme engine. However, on page 188, the author states where you can find an example page but there's almost nothing on that page — as of this writing — aside from links to pornographic photos and video. Did the author intend for readers to find them? Either way, it signifies poor judgment on the part of the author.
For many PHP developers, working with form pages is oftentimes the most problematic part of creating a Web site. Fortunately, this book tackles the topic, in Chapter 8, as it pertains to Drupal sites.
In spite of the terribly sloppy writing and editing (both narrative and technical), Drupal developers interested in creating their own themes, or modifying those created by other developers, will find straightforward and detailed coverage in Drupal 5 Themes.
Michael J. Ross is a Web developer, writer, and freelance editor.
You can purchase Drupal 5 Themes from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
On the positive side of the ledger, Drupal 5 Themes is a solid introduction to Drupal theming, and the author takes his time in explaining the key concepts. Extensive use is made of sample code, in addition to screenshots of themed pages, admin pages, directory trees, and more.
On the negative side of the ledger, the book contains many small errors — even for a first edition. There are far too many misspellings: "new-comer" (page 8), "where ever" (page 10), "blocks manager" (on the same page — even the same paragraph!), "in depth" (as an adjective, on pages 23 and 24), "jump start," "down side" (both on page 27), "sites" (as a possessive, page 54), "some where" (page 87), and one that undermines the technical credibility of the author, "FavIcon" (page 50). Sadly, there are numerous other errata. For instance, on page 47, we stumble over "to the tailoring an existing theme." On page 10, "assemble to core" should instead read "assemble the core." In several instances, "comprise" is mistaken for "compose." The alert reader will spot other signs of sloppy editing: One pages 18-19, the author should have chosen either "Tables Free" or "CSS-based," and be consistent. The penultimate paragraph on page 123 has double periods. The synonym of "theme" that is posited, "template," is related, but not synonymous; but the common term "skin" isn't even mentioned. On page 188, "page-blog-tpl.php" contains a typo.
Some of the author's phrasing is quite awkward, e.g., "Dev Server" (page 120) apparently means a local Web server. In fact, throughout the book he flip-flops on using lowercase or title case for such terms as "block" and "region." The overuse of title case is also found throughout the book, with some of it almost laughable, e.g., "... the Big Picture." In terms of the writing style, it could certainly be improved, such as judicious use of commas where needed — particularly in the countless run-on sentences. In general, this book contains more errata and style gaffes than any other computer book I have ever seen, on an absolute basis — even worse per page, considering it has perhaps half the number of pages of the typical computer book.
Turning to the technical material itself, there are inconsistencies as well. For instance, some URLs contain root directory slashes, while others do not. Some menu breadcrumbs use ">" as a delimiter, while others use "|." Furthermore, the Drupal menu breadcrumbs (e.g., "administer>themes") should be in sentence case, not lowercase, to match Drupal's names. Fortunately, none of the aforementioned flaws prevent the reader from understanding the book's material, but they reveal insufficient effort in the writing and editing phases, and suggest that other, less obvious, mistakes were possibly made.
In terms of the book's production, it could be improved. Some of the images are highly pixelated — especially the screenshots of directory trees. What will perhaps be most annoying to some readers, is the publisher's use of a glossy black ink that causes each page to reflect one's reading light. One might initially hope that this is an unavoidable disadvantage of the publisher perhaps choosing an environmentally friendly ink, or some similar reason, but nowhere in the book is the type or choice of ink mentioned. This suggests the poor choice was made for economic and not ecologic reasons.
The chapter summaries add nothing to the discussion, and could be removed without loss.
We now turn to specific chapters. In Chapter 2, the author discusses how to install and configure themes, and also touches upon global configuration settings, as well as module and block management. This information is put to use in the second part of the chapter, which covers the customization of Garland, the default Drupal theme. Some of the material in this chapter could prove puzzling or even misleading to many readers. The author states that enabling a theme and setting it as the default, applies it to "both front end and back end of the site" (page 31). Actually, it only changes the front-end theme; the back-end theme is set via Administer > Site configuration > Administration theme; oddly, he actually acknowledges this much later. In the theme configuration screenshots in Chapter 2, the "gagarin" theme is missing, even though it was supposedly installed earlier. On page 40, the author instructs, "To access all the user permissions and configuration screens in one place, view your administrator console by module." But Administer > Site building > Modules is not where the administrator sets user permissions and blog configurations. In the discussion of page specific visibility settings, the third radio button option (entering PHP code to control the visibility of the block) is only displayed if the user has enabled "use PHP for block visibility" in Administer > User management > Access control. The figure caption on page 50 could give a reader the mistaken idea that Drupal renames the custom logo image to "garland_logo.gif" automatically, prior to the configuration settings being saved, which is mentioned afterwards. On page 58, the illustration shows PHP code that appears to contain an extraneous tag, , which is probably a holdover from the illustration on page 56; in fact, it breaks the code, because the presence of that string always effectively returns TRUE. On pages 86 and 87, the PHP code contains four back ticks, which should be replaced with straight apostrophes.
Theme engines, specifically PHPTemplate, is explored in Chapter 3. The author explains the primary functionality of the six files that constitute this built-in theme engine. These are illustrated by comparing two PHPTemplate themes — Garland versus Gagarin. The chapter concludes with brief overviews of three other theme engines, PHPTAL, Smarty, and PHP XTemplate.
Modifying a theme to customize a Drupal site, can be done in one of two ways, or a combination of the two, which is the typical approach: overriding default CSS rules, and overriding themeable functions. Chapters 4 and 5 explain how to do so, with the former containing a list of themeable functions organized by functionality. Chapter 5 covers the details of overriding Drupal CSS and functions, including a valuable discussion of the various options open to the developer for overriding functions, including step-by-step instructions. The chapter concludes with a brief explanation as to how to intercept template files.
Chapters 6 and 7 form the heart of the book, because they explain the details of modifying an existing theme and building a new one from scratch. Anyone interested in learning how to style their Drupal-based Web site with maximum flexibility, will find these two chapters of value. However, there are several pitfalls the reader will want to watch for: Early in Chapter 6, the author instructs the reader who is following along to rename the theme-specific functions in the template.php file from "zen_" to "tao_." Yet this is insufficient, because the page formatting for this new theme, tao, already differs from Zen's. This is likely due to the theme PHP files not finding one or more CSS files that still contain the name "zen." In fact, to completely replace the old theme name throughout Zen's code, one needs to change nine other PHP files. In the section describing how to set up the menus, the weights for the "Home" and "Contact Us" links are supposedly set to 10 and -10, respectively, which would place the former to the left of the latter; yet the illustration on page 148 shows the opposite. The "Blog Entries" weight should be -10 instead of 10. The weights for the footer navigation menu links appear to be equally messed up. In addition, both instances of "yourdomain" is followed by an erroneous space. Frankly, it is as if the book had never been technically edited.
Chapter 7, the longest in the book, is possibly the one that will receive the most study by readers who wish to learn the intricacies of making their own theme from the ground up. The author provides a step-by-step explanation as to what is involved in creating a new theme, and the advantages and disadvantages to alternative approaches. He uses a sample theme, "Bluewater," to illustrate the ideas. The problems with this material are fairly minor: The diagram caption on page 152 states that the elements within the CSS are ordered alphabetically, and yet no alphabetical ordering is apparent. In fact, the ordering doesn't even match that in the page.tpl.php file. In addition, page.tpl.php contains a couple curly quotes, though this does not affect its functionality. Aside from these issues, the discussion is quite thorough, and the reader ends up with a fully functional — though not especially attractive — Drupal theme. The chapter concludes with coverage of template variables, the use of multiple templates, dynamic theming, and developing a theme without the use of any theme engine. However, on page 188, the author states where you can find an example page but there's almost nothing on that page — as of this writing — aside from links to pornographic photos and video. Did the author intend for readers to find them? Either way, it signifies poor judgment on the part of the author.
For many PHP developers, working with form pages is oftentimes the most problematic part of creating a Web site. Fortunately, this book tackles the topic, in Chapter 8, as it pertains to Drupal sites.
In spite of the terribly sloppy writing and editing (both narrative and technical), Drupal developers interested in creating their own themes, or modifying those created by other developers, will find straightforward and detailed coverage in Drupal 5 Themes.
Michael J. Ross is a Web developer, writer, and freelance editor.
You can purchase Drupal 5 Themes from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
I used to use Postnuke for one of my sites. I designed my own theme for it, and it was pretty nice - you can see a PARTIALLY saved version of it here. I figured out how to make it by looking at the code for existing themes, which was not too dissimilar to standard HTML, and hacked around with it. In version .750 they switched to a new theme system called Xandria, breaking my old theme. I never managed to convert it to Xandria, because I find the Xandria language to be incomprehensible. The documentation, what little of it there was, was equally incomprehensible, and there were no (working) conversion tools.
So I simply stopped using Postnuke.
Kevin Smith on Prince
Wow, just in time for Drupal 6 to come out! heh
Actually I might buy this book...
Dr.E
Eric Aitala
www.f1m.com
The CMS I've been using for three years now just uses a basic HTML page as a theme, you add simple tag-based elements such as [*pagetitle*] or [*content*] to get the dynamic content for each page requested. You can just copy any web page's source and replace the relevant text output sections with these dynamic tags, for everything from menus and login forms to complex AJAX data grid displays.
http://modxcms.com/
Money for nothing, pix for free
Money for nothing, pix for free
Pot calling the kettle black?
In all seriousness, instead of blaming the author for these problems, the reviewer should be blaming the publisher. Where were the editors? As the quote shows, mistakes are easy to make, but when it comes to print, any half-decent publishing house should be catching them.
... is (unless they've fixed this) that if you want to update your site, you have to update every incremental update to finally get the latest update. basically the whole updating thing is a lot more complicated than it should be.
Our company makes Drupal websites for many customers with ease. It is very flexible and easy. I can't imagine needing a 260 page book to work with it. http://www.kirkhamsystems.com/
Drupal is a nice example of how a piece of junk software can become popular. Their code structure looks like OO, but it isn't. Instead, they use their own hooking system, which makes the software slow (talking about hundreds of DB queries to build a simple page) and more complex then necessary. No offense, but the fact that Drupal is popular tells me more about the programming skills of the average webdeveloper then it tells me about the quality of Drupal.
It doesn't have to be like this. All we need to do is make sure we keep talking.
I'm interested in blogs/CMS's/whatever that support moderation and decentralized editorial/administrative control. I've looked at Slash and Scoop, but they're a bit unwieldy for a mere mortal like myself, and (I think) are difficult/impossible to install on a shared hosting server.
Which scripts are the best for this sort of thing? Is Drupal the way to go?
There are free Drupal themes available on the Net, but I haven't been able to find a nice one with light text on dark background. For some reason there seem to be many more free themes for e.g. Joomla.
I've not read the book, but it occurred to me that some of the errors complained of above might not be errors, or at worst just insufficiently explained Drupalisms.
You might be conflating relative URLs with "Drupal paths" here. Most Drupal sites these days use Apache mod_rewrite to convert a URL like:
to:
The distinction between Drupal paths and URLs relative to the site's base directory is important, because your Drupal site might be in a subdirectory of your web server's root directory (eg. http://www.example.com/mysite/).
The breadcrumb delimiter is itself themeable. This would just be reflecting real world experience, so I can't see any benefit to this degree of consistency.
I would have expected that anybody ready to tackle Drupal theming would be familiar with the concept of using a development server (possibly but not necessarily on your local machine) to safely make modifications before transferring them to the live site, and that a definition here would be irritatingly redundant.
Why has no one mentioned the new javascript theming assistant for Drupal 6. Simply click in an area and it will tell you what function creates that output and it allows you to very easily patch up themes!
Off with his head!
Actually I get a little tired of hearing about "skins". There's more to a theme than gathering up a set of alternate graphical elements. (When I hear "skins", for example, I'm more often than not, going to think about the pretty much useless variations one can make to the appearance of something like XMMS, most of which -- though they may make it look like it was designed by Giger -- almost always make its display next to unreadable.) A theme can include font selection and, if it's CSS-based, a customized way of dealing with just about every element of the web page. Geez, more than a few of the reviewer's complaints seemed just a little too picky. A double period at the end of a sentence! I guess we ought to be asking for a price reduction at the register since the book is so obviously damaged.
There are more mistakes regarding Drupal in the review than are pointed out in the book.
/admin in Drupal 5 by default is the Administration by Task console. It groups administrative options by grouping them into various task-related subgroups. Across the top of the page there is an option to display those options grouped by the module they are associated with, instead of the tasks they perform. The URL for that is admin/by-module, not admin/build/modules.
Some menu breadcrumbs use ">" as a delimiter, while others use "|."
Because some Drupal themes use > as the breadcrumb delimiter, and some use |. This is entirely up to the theme author. Very likely those entries were cut and pasted directly from the Drupal output being referred to.
The author states that enabling a theme and setting it as the default, applies it to "both front end and back end of the site" (page 31). Actually, it only changes the front-end theme; the back-end theme is set via Administer > Site configuration > Administration theme; oddly, he actually acknowledges this much later.
Because it only needs to be acknowledged later. By default, the setting for Administration theme is "system" which makes the administration (backend) theme the same as the site's (frontend) theme. It can be overridden by the site administrator to be any other theme, but until this default setting is changed (in other words, until the existence of it is mentioned) the statement above that setting a theme to default affects both the frontend and backend is accurate.
In the theme configuration screenshots in Chapter 2, the "gagarin" theme is missing, even though it was supposedly installed earlier.
So?
On page 40, the author instructs, "To access all the user permissions and configuration screens in one place, view your administrator console by module." But Administer > Site building > Modules is not where the administrator sets user permissions and blog configurations.
Administer > Site building > Modules is not the administrator console by module.
The figure caption on page 50 could give a reader the mistaken idea that Drupal renames the custom logo image to "garland_logo.gif"
It does. If you upload a custom logo while editing site-specific themes, the image is uploaded and given a name that labels it as specific to that theme. If you instead enter in a path to a custom logo the file is neither renamed or moved.
In the section describing how to set up the menus, the weights for the "Home" and "Contact Us" links are supposedly set to 10 and -10, respectively, which would place the former to the left of the latter; yet the illustration on page 148 shows the opposite.
You are mistaken. If "Contact Us" is weighted -10 and "Home" is weighted 10 then "Contact Us" will appear first, on the left, and "Home" will appear next, on the right (assuming there are no other menu items). Drupal's weighting system has always worked on the basis of the concept that lower numbered, or "lighter" items float to the top, while higher numbered items, or "heavy" items, sink to the bottom. Hence the use of the term "weight".
At a glance I'd say that this review is evidence that more than a passing familiarity with Drupal is necessary to provide a really useful review of a book covering this topic, unless one merely wishes to assert that one is a better copyeditor than the one at Packt.
Yet another book that sells information freely available. Not to mention one that is rather poorly written, to all appearances...