Drupal 7 Module Development - Book Review
Drupal 7 Module Development - Book Review
Join the DZone community and get the full member experience.Join For Free
Read this guide to learn everything you need to know about RPA, and how it can help you manage and automate your processes.
If you have more than a passing interest in Drupal, then you are probably aware of the significance of such a talented group of developers collaborating on this book. The author list reads like a veritable who’s who in the subculture of Drupal…
Matt Butcher works for the New York Times Company on their ConsumerSearch site. Greg Dunlap works for NodeOne, an agency in Sweden. The rest of the authors are heavy hitters at Palantir, a development firm based in Chicago.
This book does not mince words, skipping past the whole installation process, because such information is readily available online anyway. What I like best about this book is that, after the requisite introductory chapter covering the broad strokes, it gets right into building a module from scratch, aptly named First, that outputs a list of all the currently installed modules. Chapter 2 also touches on code standards (covered here), as well as how to write automated unit tests.
Chapter 3 is all about theming, and not just at a superficial stylistic level, but also how to make use of powerful preprocess functions, that allow the theme layer to edit Drupal’s output before it reaches the browser. I have implemented such techniques to make my own site HTML5, rather than the default XHTML 1.0.
With module building and theming covered, chapter 4 jumps into how to theme a module, because modules themselves typically output a varying degree of markup themselves, and can (optionally) ship with CSS to handle any custom styling. Also covered is consideration for languages that read right to left, as internationalization has been a priority even since the earliest days of Drupal. Such cases should not be overlooked if you intend to make your module publicly available for reuse.
Chapter 5 draws back the curtain a bit, so to speak, venturing into the administrative interface. Some modules do not actually affect a site’s public look and feel at all, but instead are built to facilitate a content creation workflow and/or user management. This chapter covers how to write an admin module that makes use of Drupal’s email API, sending the user a warning message if he or she is deemed to be in violation of the site’s terms of service.
Chapters 6 and 7 cover how to work with custom content and field types, using artwork as an example of a special type of content (ch. 6), with the dimensions of each piece of artwork necessitating a custom field type (ch. 7). The authors are quick to point out that Drupal itself is versatile enough to handle such cases, without needing a custom module. However, they chose this as a faux case study, simply to explain building modules that handle custom content and fields.
Chapters 8 and 9 cover permissions and security, as well as node access. One thing I have always appreciated about the community of developers around Drupal is the dedicated security team. Chapters 8 takes the same mindset, that any anonymous site visitors could potentially be nefarious, and explains the best ways to ensure that you are not leaving your site vulnerable due to exploit vectors in your module. Additionally, chapter 9 talks about conditionally showing content to various user tiers, depending on if they have the necessary credentials to view it.
In chapter 11, working with files and images is explained. Whereas previous versions of Drupal required an additional module to be installed in order to manipulate images, as of Drupal 7, this functionality is built into core. As a module developer, you can tap into the native Image API, allowing users to manipulate graphics via a web interface. The authors explain the process of adding a watermark to a photo, as well as how to desaturate, rotate, and resize images.
You will love chapter 12 if you build a lot of Drupal powered sites, and find yourself repeatedly setting your preferred defaults each time. While not about module development, per se, it covers how to bundle modules and site configuration into what’s called an “install profile.” This allows you create a custom installation of Drupal, preconfigured with everything you would normally have to do anyway.
Basically, this book leaves no stone unturned. As if the aforementioned chapters weren’t already enough, at the end of the book, there are two appendices that cover databases and security, to be used more as a reference than a tutorial.
I would recommend Drupal 7 Module Development to anyone who has familiarity with building sites in Drupal, but wants to take their prowess to the next level. The collective expertise imparted in this book simply cannot be overstated.
Published at DZone with permission of Nathan Smith , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.