Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Drupal 5 Themes

Posted by samzenpus on Wednesday February 06, @01:42PM
from the read-all-about-it dept.
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.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.

Drupal 5 Themes 25 Comments More | Login | Reply /

 Full
 Abbreviated
 Hidden
More | Login | Reply
Keybindings Beta
Q W E
A S D
Loading ... Please wait.
  • by trolltalk.com (1108067) on Wednesday February 06, @02:14PM (#22324098) Homepage Journal

    ... and then writes this:

    both instances of "yourdomain" is followed by an erroneous space. Frankly, it is as if the book had never been technically edited.

    • Re: (Score:2)

      ...both instances of "yourdomain" is followed by an erroneous space.

      The "is" is incorrect, but the "an" is fine. Am I missing something?
    • 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. Is

  • Wow, just in time for Drupal 6 to come out! heh

    Actually I might buy this book...

    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
      • Re: (Score:2)

        Well, I will probably stick to Drupal 5 for quite a while and am going to customize a third party Drupal theme (Denver) to make it do what I want...
        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
      • 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!
  • 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 repla
  • 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)

    by richie2000 (159732) <rickard.olsson@gmail.com> on Wednesday February 06, @02:32PM (#22324326) Homepage Journal

    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.
    A menu item with a weight of -10 would always be displayed to the left/above one with a weight of 10. "Lighter" values float, "heavier" sink. A "Home" with a weight of 10 would therefore be displayed to the right of "Contact Us".
  • 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 ha
  • 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.
    • Re: (Score:2)

      Actually its called Xanthia, but yah, it is not the greatest system in the world.

      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 .8 release for years.
    • Re: (Score:3, Insightful)

      I'm wondering why one would need a theme at all. Just edit the style sheets. If you look at what the people from CSS Zen Garden [csszengarden.com] do with just CSS changes, you'll wonder why you would ever need to change the HTML to create a new theme.
      • Re:Ugh. (Score:5, Insightful)

        by yelvington (8169) on Wednesday February 06, @03:03PM (#22324700) Homepage

        I'm wondering why one would need a theme at all.


        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)

        by mdavids (143296) on Wednesday February 06, @05:24PM (#22326432) Homepage

        ... 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:2, Informative)

      The instructions for the most basic methods of theme making for Drupal could be fit in a page. It's sufficient for a lot of people.

      Drupal's powerful enough, though, to allow all sorts of neat tricks - different node templates for different content types,
    • Re: (Score:3, Informative)

      Having themed in Drupal it's definitely not too complex, I was able to piece together what I needed to do from samples around the internet, and a lot of it is quite intuitive.
    • Re: (Score:3, Informative)

      It really depends on how technical you are, and if you have any skill in reverse-engineering existing themes. I can't speak for Drupal, but my Wordpress theme-building experience involves looking up functions in existing themes (show the body of the post,
    • Re: (Score:2)

      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 st

    • Re: (Score:3, Informative)

      Drupal can be themed on differents levels. From easy to hard:
      - 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
    • Re: (Score:2)

      From http://api.drupal.org/api/file/developer/topics/oop.html [drupal.org]:

      Drupal often gets criticized by newcomers who believe that object-oriented programming (OOP) is always the best way to design software architecture, and since they do not see the word "class" in
    • Re: (Score:2)

      Their code structure looks like OO, but it isn't.

      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 so
    • ... 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 painles