Drupal 5 Themes 65
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.
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.
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. |
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.
Ugh. (Score:1)
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 [archive.org]. 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
Re: (Score:2)
I am moving from Post-Nuke to Drupal because Drupal is looking much better in terms of support, modules, and future plans.
Post-Nuke had been planning its
Eric
Re: (Score:3, Insightful)
Re:Ugh. (Score:5, Insightful)
I'm wondering if you've ever done anything complex enough to require additional regions not provided in off-the-shelf themes or alternative layouts for multiple content types, or rearrangement of fields in complex content types or user profiles, or overriding microcomponents such as taxonomy links.
Theming is not limited to simple reskinning. CSS is a tool. It shouldn't be your only tool.
Re:Ugh. (Score:4, Insightful)
... which is exactly the thinking behind the Zen theme [drupal.org], which was in contention for being the default Drupal theme at the time Drupal 5 was being developed.
Having used a stripped down version of Zen as my starting point for all my themes since Drupal 5 came out over a year ago, I can say that things never work out that simply on any non-trivial site. You always end up hacking HTML somewhere. On refection I think the price you pay for all the crufty wrapper divs needed to provide you with hooks for (almost, but never entirely) every CSS selector you might reasonably want in a theme is just too high. If Firebug is an absolute necessity for understanding your own markup, then you're doing something wrong.
In Drupal 6, customising HTML output will become a lot easier for non-programmers, as a lot of stuff that previously required a PHP theme function to override, can now be overriden by template files in your theme directory.
Re: (Score:3, Insightful)
Re: (Score:3, Informative)
Drupal's powerful enough, though, to allow all sorts of neat tricks - different node templates for different content types, overriding any of Drupal's hundreds of theme_xxx functions, etc. It's really a phenomenal system for creating your own customised CMS.
Re:Ugh. (Score:4, Informative)
Re: (Score:3, Informative)
Re: (Score:3, Insightful)
You know that people have written 260 page books on using Google, right? People write big books about simple things. Drupal's theme system is rapidly converging on that sweet spot of being as simple as possible, but no simpler. If you know how to make a static website from valid xhtml and CSS, you can pick up the zen theme and start filling in the blanks.
It's actually easier than writing CSS from scratch, because the major hassles (how do I do three column layout again? Why is ie rendering it like that?)
Re: (Score:3, Informative)
- some themes come with settings that can change colours in the admin backend
- CSS level (download a theme or use the default, change around some CSS, done)
- edit or create template pages, which use standard php
- use a different template system such as smarty
- edit or create theme_xxx() functions
Especially if the book covers the creation of theme_ functions and their proper use, I can understand they use 260 pages to explain.
Drupal has its weaknes
Re: (Score:2)
Drupal theming is still pretty hokey in a lot of ways (for example, the whole way it deals with external CSS files is very poorly thought-out), but this:
...strains my credibility :-) I've customized themes for most of the bigger open source CMS packages, and Postnuke was one of the very, very worst. Simply no flexibility at all--and this was during the .7xx phase.
In terms of relative simplicity, Drupal themi
Spending a paragraph being a grammar nazi ... (Score:5, Funny)
Re: (Score:2)
The "is" is incorrect, but the "an" is fine. Am I missing something?
Re: (Score:2)
Yes - you are missing something. Once you replace "is" with "are", the "an" is extraneous. So, for that matter, is "erroneous"
"... both instances of "yourdomain" are followed by space"
You already know the author is citing this as a mistake - no need to be overly repetitive unless you're getting paid by the word.
Re: (Score:2)
Re: (Score:2)
Speaking of technical editing, why is it so common to see crap like yourdomain in books? The .example TLD along with example.com etc. have all been reserved for this purpose by RFC 2606 [ietf.org] so examples don't conflict with domains that are already in use. Isn't this the sort of thing a technical editor, as opposed to a normal editor, should pick up on? It just reminds me of the stupid novel [slashdot.org] and film [feardotcom.com] writers that title their works with domain names already in use by others. It's just not necessary.
Re: (Score:2)
How common is it? Do you have data?
Oh, I dunno. "Example.com" just doesn't have the same dark overtones that "Fear.com" does.
Re: (Score:1)
More common than it should be.
The book in question provides one example. Since there should be no examples (see RFC 2606), the existence of one example provides sufficient data to prove the previous assertion to be true.
Er, Drupal 5? (Score:2)
Actually I might buy this book...
Dr.E
Re: (Score:2)
There, I just condensed 260 pages that costs money into something free and easy to do. As far as modifying your CSS to find your custom needs, well, that's for a completely different book and one that I would actually read -- if it helped more than what I've been able to learn myself online.
Re: (Score:2)
I need to be able to work my users into the new Drupal system since I've been using Post-Nuke for 6-7 years now.
Dr.E
Re: (Score:2)
Why when you can view everything you need to know about Drupal themes (including version 6+) here [drupal.org]. You basically unpack the theme, put it in the themes directory, and go into the admin panel to enable it.
There, I just condensed 260 pages that costs money into something free and easy to do. As far as modifying your CSS to find your custom needs, well, that's for a completely different book and one that I would actually read -- if it helped more than what I've been able to learn myself online.
"Download phpBB" -- A book on writing a forum system in PHP "condensed" into 2 words!
Re: (Score:1)
the theme chapter in that is about 40 or 50 pages long but gives you more than enough to build complicated themes. normally i
Re: (Score:1, Troll)
A whole book just for themes? (Score:2)
http://modxcms.com/ [modxcms.com]
Re: (Score:1)
Re: (Score:1)
Re:A whole book just for themes? (Score:5, Informative)
The power of Drupal's approach to theming is that you can do as little, or as much, customization of detailed component formatting as you want.
It's a site development platform, not simple blogware that lets you play with look and feel. This is why the Onion [theonion.com], HamptonRoads.com [hamptonroads.com], New York Observer [observer.com] and Ozzy Osborne's website [ozzyosbourne.com] can all run Drupal but not look or act like my weblog [yelvington.com] or JumpTV [jumptv.com].
Re: (Score:1)
http://community.enemyterritory.com/ [enemyterritory.com]
I see that in the case ov your blog you took advantage ov Drupal's approach to theming and did as little customization of detailed component formatting as possible. Next time at least change teh favicon!!!
Re: (Score:1)
But CMS's are like operating systems to people I find. Reasons for loving or despising them are as varied as the individuals who use them. I hated all CMS's that I had to learn a templating system rather than being able to use standard HTML and that, together with MODx's modular, don't have to hack the core approach, and the wayfin
Errata error? (Score:2)
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.
Actually, that setting DOES change both the main and admin theme, unless the admin theme setting is specifically changed to another theme. Its default is to follow the main theme setting.
...another (Score:3, Informative)
On Errors (Score:2, Informative)
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.
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.
Re: (Score:1, Insightful)
Uh, did you visit the reviewer's webpage as linked in the review? He's not the best at his job, either.
the problem with drupal... (Score:1)
Re: (Score:2)
... 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.
I upgraded from 5.5 to 5.7 without hitting 5.6. Just removed the main drupal directory, replaced it with the 5.7 directory, then moved the files (uploads) and 3rd party modules back into place. Then visited their update scripts. By far the most painless upgrade experience I've ever seen on an PHP-based item.
I don't claim to be an expert on Drupal, and I did try this on a test server first.
Re: (Score:1)
Re: (Score:1, Insightful)
Quality of Drupal (Score:1)
Re: (Score:3, Informative)
Re: (Score:1)
Re: (Score:2)
How does it look like OO? It's functional. It doesn't pretend to be object oriented. Maybe you're confusing modular code layout with classes?
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.
What does the choice of building a custom hooking system have to do with the number of database queries? An object oriented design could easily caus
Re: (Score:1)
Re: (Score:2)
Re: (Score:1)
Uh huh...
One way to spot a rookie is that they think whether something is OO or not is relevant to whether it's efficient or even well-designed or not.
Re: (Score:1)
Scripts with moderation support? (Score:1)
Which scripts are the best for this sort of thing? Is Drupal the way to go?
Free Drupal themes (Score:2)
Some possible non-errors (Score:2)
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 relativ
More mistakes in the review. (Score:1)
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" (
Why? (Score:2)