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."
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.
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 |
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.
umm (Score:5, Insightful)
Re: (Score:1)
Re: (Score:2)
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.
Re: (Score:2)
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)
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
Re: (Score:2, Informative)
Re: (Score:1)
Re: (Score:3, Insightful)
Re: (Score:2)
Re: (Score:2)
I recommend Plain Old Text mode and using the Preview button.
Re: (Score:2)
meanwhile, I've setup Drupal 6, installed CCK, and Views 2 and they dman fields from CCK aren't showing up so I can't use them in Views...
somebody shoot me.
Re: (Score:2)
somebody shoot me.
I'm sorry, but for insurance reasons I need a signed, witnessed, and notarized confirmation before I can take action on your request.
Re: (Score:1)
Re: (Score:2)
Unless Drupal already does more or less exactly what you need, it's probably as fast to author some code from scratch (or use a framework) rather than learn Drupals API. As such, I suspect this book has a limited market.
So you've used Drupal then? How do you find it?
Drupal User Here (Score:3, Informative)
There are some things I like about it, like the whole taxonomy thing. I'm running 6.x now and it's much faster than 4.x and better to administrate.
It's very true that drupal sites look and feel quite alike. The theming has gotten better, but still, they are all quite similar. The canned forums and mailing list manager I still don't like. Almost every contributed module relies on mysql, so ignore their claims of PGSQL.
I would say that if Drupal can do your task with a few modules, it's great. If it can't
Re: (Score:2)
Re: (Score:1)
So you've used Drupal then? How do you find it?
How do I find it? I find it here [drupal.org].
Haha, I kill myself. No seriously though, I find it to be quite a useful system. What I find irritating is the online documentation and the Drupal programmers' proclivity for changing things for seemingly tenuous or no reason, creating unnecessary headaches for those who must now update their own modules.
Anyone wanting to maintaining backwards compatibility for whatever reasons is in for some headaches.
If you have the book handy I find that the problems are minimized. Owning
Drupal Camp LA this weekend 9/13-14 at LA Conv ctr (Score:1, Informative)
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
Re:Drupal Camp LA this weekend 9/13-14 at LA Conv (Score:1)
Re: (Score:1)
Re: (Score:1)
Similar story but the other way around for me, I found Drupal to be much easier to develop with than Joomla, this was back when I first dived into the world of website development. Especially the documentation of Drupal, at the time, far surpassed Joomla's.
To me Drupal seems a lot cleaner, simpler and tidier while Joomla is a mess. I'm not sure whether the documentation is better now or not, but a year or so ago it was impossible to figure out how to develop for it.
Since my original comparison I never gave
Re: (Score:1)
don't bother (Score:2)
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.
Re: (Score:1)
Bay Area Drupal Camp also coming up in October (Score:1)