Drupal 6 Javascript and jQuery book review
Drupal, is a powerful content management system that allows you to build professional, scalable websites without needing a large amount of programming knowledge. Many books have been written about using Drupal to create content and theme the content so it matches your look in feel. However, not much had been written about improving the experience of users as they interact with your website until Drupal 6 JavaScript and jQuery was written by Matt Butcher.
The majority of Drupal 6 Javascript and jQuery is structured as a series of projects with complete source code and detailed descriptions of how the project works and the design decisions the author made as he wrote the code. Projects real-time notifications for new comments, a templating system, a simple text editor, an rss viewer, auto-completion for search fields, collapsible blocks, and more. All projects are so well explained that anyone with basic programming knowledge in any language will be able to follow along, but experienced developers will not find the explanations tedious. This is an extremely difficult balance to strike in a technical book. I was also impressed that many of the projects were practical and could easily be extended for use in websites. The projects even gave me ideas that I could use for sites that are not Drupal based.
The book starts with a brief introduction to Drupal and the elements with Drupal that will be manipulated throughout the book. With that explanation done, the book quickly moves introduces as to two tools that will make developing Drupal based sites with Javascript easier. The first tool is Firebug a Firefox extension which includes a powerful Javascript debugger (plus loads of other great tools). The second tool is the Devel module for Drupal. The Devel module allows you to inspect much of what is going on behind the scenes in Drupal. The Theme developer information is especially relevant for this book.
After all of the tools are been introduced, the meat of the book starts and we learn the Drupal way of adding JavaScript to our site. Some of the most valuable advice in this section are the tips which will especially help novices to learn the basics. After a quick project to demonstrate including Javascript, we dive into jQuery. The introduction to jQuery section covers the basics of jQuery and demonstrates using jQuery outside of Drupal before a presenting a project with the two combined. Using this approach definitely makes it easier to understand the jQuery syntax if you haven't had a chance to try jQuery before.
After our tutorial on jQuery, we turn our focus back to Drupal and the functionality contained drupal.js in Chapter 4. The majority of the time is spent talking about Drupal behaviors which allow you to define code which runs when a specific condition is met. The chapter also explores other key functionality which Drupal provides to JavaScript developers. Projects in this section make extensive use of jQuery to minimize the amount of custom code which needs to be written. It's also nice to see the author include information about making your code more secure, a topic which is often ignored in the interest of streamlining code.
Next we move onto translations. I have to admit that this isn't the most exciting section of the book. However, my next project will be a multi-lingual site so I'm sure that I will be referring back to this section extensively during that project. Although the topic is a little dry, Matt does an excellent job explaining all of the intricacies of handling translations in JavaScript.
As we move out of the translation section, we journey into the world of themeing from a JavaScript perspective. Themeing is essential to every Drupal project regardless of whether you are using a contributed theme or creating a custom theme that you build from scratch. The themeing system within Drupal is remarkably sophisticated. However, much of that sophistication is not available within JavaScript. Therefore, the project for this chapter builds a framework to support themes in JavaScript. The themeing capabilities are very similar to those found within PHP and include the ability to define templates which can be overridden by other developers allowing presentation to be implemented independently from business logic. Although the project itself is complicated the explanation is easy to follow and well documented. The themeing system is used in all future projects throughout the rest of the book.
The next topic is AJAX and webservices. The projects in this chapter include a webclips project which displays a random item from an RSS feed and real-time comment notifications. The webclips project uses an XML feed to get data and the comment notification uses a JSON based data feed. The JSON feed is created using the Views module. The techniques used in this chapter can be used in a wide variety of projects.
Up to this point in the book, all code has been implemented within Drupal themes to keep the emphasis on JavaScript and jQeuery. In chapter 8, the book explores adding Javascript to a Drupal module. This is done to make the code easier to deploy and independent of the theme you are using on your site. The main project in this site focuses on extending the Simple Text Editor built in chapter 4. The revised editor adds additional capabilities to the editor, makes additional use of jQuery, and makes the code easier to maintain and extend. As always, the code is easy to understand and expertly described.
The final chapter features 2 projects which both a very cool factor and could be used on a majority of websites. Rather than describing them in detail here, I'll leave it to you to read more about them.
You can buy Drupal 6 JavaScript and jQuery directly from PACKT publishing.
I highly recommend Drupal 6 JavaScript and jQuery to anyone building sites with Drupal that want to make their sites more interactive and leverage the power of JavaScript.

