Using Drupal
Angela Byron
Addison Berry
Bruno De Bondt
Copyright 2012 Heather Berry, Angela Byron, and O'Reilly Media, Inc., Heather Berry and Angela Byron
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.
Nutshell Handbook, the Nutshell Handbook logo, and the OReilly logo are registered trademarks of OReilly Media, Inc. Using Drupal , the image of a dormouse, and related trade dress are trademarks of OReilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and OReilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
O'Reilly Media
Foreword
Dries Buytaert
Drupal founder and project lead
Drupals modular architecture and open source nature make it a popular PHP application framework and content management system for hundreds of thousands of web developers around the world. More than 900 people contributed code and ideas to the Drupal 7 release, and even more are responsible for developing and maintaining more than 15,000 contributed modules that can be used to extend Drupals functionality.
The size, passion, and velocity of the Drupal community, combined with Drupals strength as a platform, allow incredible things to happen. Every day, new modules are contributed and existing modules are improved upon. Whether these modules are created to catch up with the latest trends on the Web or to invent completely new paradigms, the Drupal project continues to expand in many different directions.
The beauty of all these modules is that they empower website builders to assemble rich and powerful websites quickly and easily without having to be a programmer. Millions of people are using Drupal to build personal blogs, corporate websites, intranets, online photo galleries, job posting boards, conference websites, and more.
Unfortunately, the challenge for many of these site administrators, and even seasoned Drupal developers, is to try to make sense of all these modules and the ever-expanding Drupal universe. What modules should you use to build a newspaper website? What modules should you use to build an intranet? What modules are best avoided because they are being deprecated by better ones? What modules can be used on really big websites that serve millions of pages a day? Navigating your way through the Drupal world can be daunting.
This book cuts out a lot of the research time and helps you dive headfirst into Drupal. It does an excellent job of explaining how to rapidly assemble a wide variety of websites with some of Drupals most commonly used modules. Whether youre new to building websites or an experienced programmer, this book is full of useful information. Just as I did in the first edition, I promise that by the end of this book, youll be much more prepared to build the Drupal site of your dreams.
Preface
Audience
Who is this book written for?
If your lead developer cant seem to shut up about this weird Drupal thing, and you want to figure out what on earth shes talking about, this book is for you.
If your boss has approached you and said, We need to build a site that has X, and fast! and X is a photo gallery, a product reviews section, an ecommerce store, or any of the other projects covered herein, this book is for you.
If you know your way around Drupal, but have found yourself paralyzed by the sheer volume of contributed modules, and need help figuring out which ones are worth looking at, this book is for you.
If you consider yourself well versed in Drupal already, but want to broaden your horizons by learning about some useful modules that you may not have encountered yet, and learn best practices for building powerful Drupal websites, this book is for you.
If youve been building Drupal sites for a while in Drupal 6, but are new to Drupal 7 and want to find out whats new and different, this book is for you.
If youre completely new to creating websites and installing web-based scripts, this book probably isnt for you, yet. We assume that goofy acronyms like PHP, FTP, URL, ZIP, and HTML are in your working vocabulary. Likewise, if youre interested in hardcore, nitty-gritty details about Drupals API functions, this book isnt for you: our focus here is on pointy-clicky stuff: combining existing modules to build out functionality, rather than creating new ones.
If youre one of the rest of us, who fall somewhere between total newbie and computer science professor, we hope that this book provides you with an invaluable reference to building practical websites with Drupal.
Assumptions This Book Makes
Youll need access to a computer or server running PHP 5.2 or higher, along with a web server (Apache preferred) and database (MySQL recommended). For local development, there are several all-in-one Apache/MySQL/PHP packages available such as WAMP for Windows or MAMP for Macs. Visit http://drupal.org/hosting for a list of Drupal-friendly web hosting companies (with referrals benefiting the Drupal Association), and visit http://drupal.org/requirements to read more about Drupals system requirements.
You will also need to install Drupal, and the hands-on chapters assume that youre using the books source code. contains a list of all of the modules and themes that are used for each chapter so you can re-create them.
A Note About the Modules Used in This Book
Drupal is constantly moving and its community-contributed module world is constantly shifting. The source code for the book provides the versions that the chapters were written with, and as time moves on, the versions available on Drupal.org will most likely change. Sometimes changes dont dramatically affect how things work, but other times they do. For many chapters, the hands-on sections will apply for a very long time or change so little that they will still be quite easy to follow. But even if the user interface for a module changes dramatically a year down the road, after using this book and walking through various examples, you should be equipped to explore the new functionality on your own. In addition to the specific hands-on recipes, you will also learn tips and best practices for how to cook generallythat is, how to learn about modules on your own.
Also keep in mind that the Spotlight sections, which discuss module features and comparing modules, along with , which discusses how to evaluate modules, provide a good foundation for you to make these evaluations on your own. You can do your own comparisons as newer modules come out and make the best decisions for your use. This book is intended to not only be a guide but also a springboard for your own mastery of the Drupal contributed project world.
Warning
If you are just starting out with Drupal, we highly recommend sticking with the books source code, which will always match the books text and screenshots. Once youve made it through the books examples, upgrading to the latest code of the day will then just be a matter of negotiating some minor differences/enhancements around what you already know.