Anyone who has been paying attention knows that I have been doing a ton of reading lately on Drupal 6. I admit it, I have a tendency to get interested in something and then consume every bit of information about it that I can find. I recently read a book on pure JavaScript because I noticed that Drupal version 6 ships with a Drupal JavaScript library (drupal.js) as well as a fairly recent and powerful library that is gaining followers rapidly called jQuery.
I have been waiting for this book to come out for months, since I first heard that it was being written. Matt Butcher and Packt Publishing released Drupal 6 JavaScript and jQuery last month. Now that I have had a chance to read it, I must say that it does not fail to please.
What I wanted to learn was why Drupal chose to include JavaScript in the Drupal core, what it is used to accomplish and how. I am very familiar with HTML and CSS, and am reasonably adept at reading and modifying PHP when necessary, so all the other main parts of Drupal are built using tools I know and understand. I wanted to find out how and why I would want to take advantage of the stated and implied benefits of including the free and open source jQuery library in sites I administer and design using Drupal.
The books starts off with a very quick introduction to Drupal. It is obvious that the intended audience is not newcomers, and that this is not a basic introduction level text. It is assumed that anyone reading this is familiar with web site creation and administration, web hosting basics, and knows how to install a Drupal site that uses the default theme. You get a quick tour of the main core features of Drupal and some nice web browser tools for developers. Then we get to the meat of the book.
Starting in chapter two we learn how to work with JavaScript in Drupal by writing a short js program and discovering how to include it in a node by incorporating a link to the script in a theme. This is a clear and great beginning.
Chapter three is dedicated completely to the jQuery library, what it is capable of doing, and how to use it the Drupal way instead of reinventing the wheel. The basic point here is that it is a lot easier to use a library to perform complex tasks than it is to write a complete JavaScript function, which would then need to be adapted for different browsers, and it is easy to call those library functions within Drupal because the Drupal developers have chosen to create ways to do so that are even easier than calling those library functions would be in a standard flat HTML/CSS page or some other content management systems. There are useful examples throughout such as how to make a set of announcements display one at a time at the top of your page, fading in and out, so that you can give several tidbits of information to your site guests without requiring all of the space on your page. Cool stuff.
The book contains useful information on how to use the drupal.js library, written by the Drupal developer community, to do many tasks, such as the sample collapsing blocks project that lets guests choose whether to allow information to be displayed or to shrink boxes so that there is more space on a page. We learn how to use js to create beautiful effects and help with site theming, how it can be used to translate your site into other language for guests, and even how to build your own modules.
I have only scratched the surface of the book. As I admitted in my post on the JavaScript book, I am still learning the language. By intent, jQuery is a huge time saver and makes incorporating client side functions into your site easier than using the language alone, and the way the Drupal community has chosen to incorporate that library and write their own in addition makes it still easier. I am glad I picked up the book. Now, if you will excuse me, I need to go play.
I haven’t really worked with Drupal much. However, I did spend some time today working with jquery for the first time. It’s really awesome stuff.