Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming

Learning Drupal 6 Module Development 39

Michael J. Ross writes "Of all the content management systems (CMSs) that a Web developer could use for creating a new site, the best ones allow the developer to extend the chosen CMS's capabilities, by adding new functionality, in the form of third-party modules. This is one of many reasons why Drupal is growing in popularity: Developers can choose from hundreds of Drupal modules but not all functionality that a developer might want has been captured in a module, and many of the modules are unfinished or otherwise limited in capabilities. Fortunately, PHP programmers can create their own modules, and one way to get up to speed is Learning Drupal 6 Module Development, authored by Matt Butcher."
Learning Drupal 6 Module Development
author Matt Butcher
pages 328
publisher Packt Publishing
rating 9/10
reviewer Michael J. Ross
ISBN 1847194443
summary A step-by-step guide to creating new Drupal 6 modules
Published on 10 May 2008 by Packt Publishing, under the ISBNs 1847194443 and 978-1847194442, the book is intended as a tutorial for developing your first Drupal 6 module; yet it also explains how to create themes and custom content types, how to use external XML APIs, and how to add AJAX functionality to your Drupal site using jQuery.

The book spans 328 pages, grouped into nine chapters, each devoted to a major topic of Drupal module development: Drupal's architecture and primary concepts (nodes, users, blocks, menus, etc.); an introduction to building a new module; Drupal's theme system, and how to create a custom one; module theming; using JavaScript, AJAX, and JSON; creating a custom administration module; creating a new content type, using the CCK; filters, input formats, hooks, actions, and triggers; installation profiles, how to develop one, and how to package a distribution. Throughout the book, the author illustrates key ideas by applying them to a sample Web site, named the Philosopher Bios. The material assumes that the reader has a solid understanding of the essentials of PHP and SQL, and familiarity with Drupal's administration area. But no advanced PHP or MySQL knowledge is required, nor prior experience creating Drupal modules and themes.

Packt Publishing has made available a Web page for the book, where visitors can order the book (print and electronic copies), download the book's sample code, provide feedback to the publisher, send in a question, read a summary of the book or the table of contents, and obtain a sample chapter (Chapter 2 — "Creating Our First Module"). One would expect to find a link to errata reported for this specific book, but this page does not have such a link. In fact, none of the book profile pages on Packt Publishing's site appear to have links to their respective errata. Instead, the visitor must go to their support page, specify the book of interest (the drop-down list should default to the last book review, but it does not), and finally click on the errata link, which should have been on the individual book's page. After clicking a link, a small and non-resizable browser window pops up, listing the known errata.

To Web developers unversed in Drupal's architecture and the use of modules to extend Drupal's core capabilities, the first chapter of this book should be quite valuable, because the author explains how Drupal's functionality has been logically organized into modules. For developers unfamiliar with CMS modules, the author sums it up nicely: "A module is a bundle of PHP code and supporting files that use Drupal's APIs and architecture to integrate new functional components into the Drupal framework." As noted earlier, the author presents overviews of the most critical Drupal concepts, including core modules, hooks, themes, nodes, comments, users, blocks, page rendering, menus, and forms. Unlike what is found in far too many programming books, the explanations in this chapter are generally quite complete, authoritative, and clear — with the exception of the last note on page 8 pertaining to system modules. The chapter concludes with a brief discussion of the demonstration site created in the book, as well as some developer tools recommended by the author.

In the second chapter, readers learn the basics of creating a module — in this case, one that accesses a philosophy reading list from Goodreads. Anyone who does not yet own a copy of the book, can quickly see the overall style of the book's information and presentation, by downloading the aforementioned sample chapter. There are few blemishes in this chapter: A short (and apparently non-facetious) phrase in one of the notes, "Drupal is meticulously documented..." (page 30), should come as a surprise to anyone who has stumbled into one of the gaps in Drupal's online documentation. The reader should beware that the code for the two private functions used in the sample module, differs between the book's code and that in the download archive, with no indication to the reader from either source as to which is to be preferred, if any. The book's code has other problems, as described in the errata. Also, tags such as "<channel/>" and "<item/>" may give the reader a false impression that those are empty tags (i.e., single tags, and not paired open/close tags). Unfortunately, this nonstandard and confusing notation is used throughout the book.

Theming a Web site is an important part of making it attractive and more usable to site visitors, and Drupal, like any solid CMS, has built-in support for applying themes to a site. In the third chapter, the author explores Drupal's theme system and theme engines, as well as how to create a new theme, and how to use Drupal's hook system for overriding a template function. The discussion is better than that seen in any other book, but could be further strengthened if the author were to explain the reasoning behind some of the suggested practices, such as making redundant copies of a parent theme's images for a sub-theme. Any readers implementing the "descartes" sub-theme should note that template.php, in the download code, begins with "<?" and not "<?php," which will cause problems if their PHP has short_open_tag set to Off. Chapter 5 extends the ideas presented earlier, and shows the reader how to create a new module with a default theme. The discussion of how to register a theme and, more specifically, the naming conventions, is in some places rather turgid — not due only to the writing, but partly Drupal's overriding scheme. But it does not help to have array keys such as "theme_function_name" mentioned in the text but not in the code (should it be "<theme function name>," following his earlier naming convention?). Partway through the fourth chapter, the author acknowledges that the reader may be getting lost in the terminology, and clarifies it. This is a worthy practice that could have been employed in several other places in the book (and by the authors of other programming books).

In the fifth chapter, readers will find a detailed discussion of how to leverage the power of AJAX, jQuery, and JSON to allow modules to refresh with changed content, without requiring Drupal to reload the entire Web page. Chapter 6 explains how to create a module with an administration interface, as well as how to use the powerful Forms API (FAPI), and the Mail API, among other Drupal capabilities available to the programmer. Creating a nontrivial content type that incorporate specialized fields, is the subject of Chapter 7. It is accomplished by building a new module, rather than the more common approach of using the Content Construction Kit (CCK). Readers will also benefit from an introduction to the Schema API, which is valuable for generating database-neutral SQL code. In Chapter 8, the author explains how to create content filters, actions, and hooks, as well as how to assign a trigger to an action. Like the previous two chapters, this one is fairly long and takes some work to fully digest, but doing so is essential for learning how to make the most of hooks, among the other topics. The author also shows how to indicate that your new module depends upon others. The final chapter covers installation profiles and packages, which allow the developer to put together a customized version of Drupal containing the new modules he or she has created, in addition to any dependent non-core modules.

Overall, Learning Drupal 6 Module Development accomplishes its primary goals, and provides information that would even be of interest to Drupal developers who may have no intention of ever creating their own modules and themes, but who would like to learn a lot more about Drupal's underlying architecture, and some of the differences between versions 5 and 6. The author tackled a difficult subject area, and presents enough explanations that would allow any experienced PHP programmer to work through the examples and learn from them. There are plenty of screenshots and diagrams, all of which are helpful. However, a few of the screenshots are intended to show color changes, which makes no sense because all of the screenshots are grayscale only. Rather than choosing orange and pink and other colors, distinct shades of gray would probably have been a better approach.

The book's remaining flaws — aside from those noted above — are relatively minor. The chapter summaries are of no value, and could be dropped in the interests of making the book leaner. Some of the paragraphs are overly short, and should be combined with adjacent ones (e.g., "Here is one very good reason."; page 111). Some of the phrasing is weak (e.g., "has got better and better"; page 18), confusing (e.g., "a typical template work"; page 60), or incorrect (e.g., "uninspiring"; should read "uninspired"; page 70). Other similar problems are identified in the book's errata. The author misses many opportunities to use commas to improve the text's readability, and even uses them incorrectly with parentheses (page 64). Some proper names do not have correct title case, such as "Windows explorer" (page 35). Throughout the manuscript, "hookname" should instead read "hook name." The possessive term "its" should contain no apostrophe (page 185, for example). Occasionally, a (non-critical) word is missing, such as in "content is main content" (page 33). Yet in none of these instances should the alert reader be unable to determine what the author is stating.

None of the weaknesses identified above detract from the overall value of the book. As of this writing, Learning Drupal 6 Module Development is the most promising and information-rich resource for Drupal developers interested in creating their own modules and themes.

Michael J. Ross is a Web developer, writer, and freelance editor."

You can purchase Learning Drupal 6 Module Development from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Learning Drupal 6 Module Development

Comments Filter:
  • umm (Score:5, Insightful)

    by Brian Gordon ( 987471 ) on Thursday September 11, 2008 @12:13PM (#24964897)
    Wouldn't this topic be appropriate for online documentation, not a for-pay book?..
    • Just download the torrents. It's not our job to support their outdated distribution system. They should be giving the book away for free and make money by selling tshirts at LUG meetings.
    • And why should the author give documentation to you for free? Should he not be rewarded for his time? What's in it for him to do all that for you for free? If you were him, would you spend so much time giving freebies to people who don't appreciate the fact that you've already given them free code in the first place?

      And no, I'm not a Drupal developer or even a Drupal user.

    • Like most technologies that get books, Drupal does have great online documentation. I think the idea here is that the author can give some sort of expert advice/explanation/whatever that goes above and beyond the online docs.

      http://drupal.org/handbooks [drupal.org]

      • Re: (Score:3, Insightful)

        by Se7enLC ( 714730 )

        Drupal does have great online documentation.

        You clearly haven't tried to use it for anything... It's mostly out of date and referencing old versions (5.x and 4.x). Drupal is a great codebase, but they change APIs far too often to allow the documentation to keep up.

        If you ask for advice in the IRC chat or on the forums/groups, you'll just hear "buy and read the book and don't write anything else until you've read it".

        So yeah, "The Book" is an invaluable resource, I'm sure, but I'm with an earlier poster that

    • and what do you do when you are on a plane? on a bus? subway? Red Sox game/... all without bandwith
  • by Anonymous Coward

    BTW -

    For those interested in Drupal, there
    is a FREE Drupal Camp in Los Angeles
    Calif this weekend.

    When: Sat-Sun 9/13-14
    Cost: Free (RSVP req so please hurry)
    Parking: at LACC - $12?, cheaper a few blocks away, or try the metrorail.

    More info
    http://drupalcampla.com/

    also, for those in the LA area Thu nite, 9/11/08 the SGVLUG has their monthly meeting in Pasadena, main topic mythTV, other topics - anything which maybe covered on /. ;) www.sgvlug.org

  • Don't spend your time learning Drupal.

    It is by far one of the most poorly organized CMS products out there.
    If 6 is anything like previous versions, be prepared for lacking documentation, security holes, incompatible plug-ins, spaghetti and meatballs code, and a PHP 3/4-esque procedural coding style totally devoid of objects.

    If that suits your fancy and you are a consultant looking to charge your clients ever-increasing rates, then by all means--go for it.

"The following is not for the weak of heart or Fundamentalists." -- Dave Barry

Working...