Preface
Audience
Who is this book written for?
If your lead developer can’t seem to shut up about this weird “Drupal” thing, and you want to figure out what on earth she’s 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, or a product review website, or an e-commerce site, or any of the other projects covered in this book, 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 of its more esoteric modules, and learn best practices for building powerful Drupal websites, this book is for you.
If you’re completely new to creating websites and installing web-based scripts, this book probably isn’t for you, yet. We assume that goofy acronyms like PHP, FTP, URL, ZIP, and HTML are in your working vocabulary. Likewise, if you’re interested in hardcore, nitty-gritty details about Drupal’s API functions, this book isn’t for you: our focus here is on combining existing modules to build out functionality, rather than creating new ones.
If you’re 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
You’ll need access to a computer or server running PHP, 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 (http://www.wampserver.com) or MAMP for Macs (http://www.mamp.info). Visit http://drupal.org/hosting for a list of Drupal-friendly web hosting companies, and visit http://drupal.org/requirements to read more about Drupal’s system requirements.
You will also need to install Drupal, and the hands-on chapters assume that you’re using the book’s source code. Appendix A provides some basic instructions, but if you run into trouble or want to read more detailed instructions, see the Drupal 6 installation guide at http://drupal.org/getting-started/6/install. If you are not using the source code provided with the book, Appendix C 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 don’t 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. Even if the user interface for a module changes, after using this book and walking through various configurations, you should be equipped to explore modules on your own. In addition to the specific hands-on “recipes,” you will also learn tips and best practices for how to “cook” generally, that 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 Appendix B, 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.
Contents of This Book
Beyond the initial chapters that set the stage, this book is organized as a series of recipes, each of which consists of the following structure:
- Introduction
The introduction gives an overview of what modules are covered, as well as the overall goal of the chapter.
- Case study
The case study describes the needs of a fictitious client who requires a website that can be a wiki, or have product reviews, or an image gallery. We describe some background information about the client, and go into more detail about their specific requirements.
- Implementation notes
Here we discuss various solutions within Drupal to solve the client’s requirements, and go into detail about which modules we’ve selected and why. This section compares and contrasts modules and when it’s appropriate to use module A or why module B is a dead end.
- Spotlight
Each chapter introduces one or more major modules or Drupal concepts, and the Spotlight sections provide a “bird’s-eye view” of what each specializes in and how it works. Think of this section as a miniature “product sheet” that highlights features of a given module and what it can do.
- Hands-on
After describing what a module can do in the general case, the hands-on sections will show you how to configure them by providing step-by-step “recipes” to build out the precise functionality the client requires.
- Taking it further
There are a lot of helpful add-on modules that can be introduced to a particular use case to make it even more powerful. This section provides references to additional modules that enhance the functionality built out in the hands-on sections.
- Summary
This section wraps up what we’ve learned over the course of the chapter, and provides links to the modules used, and other resources that provide more information.
Here is a list of the chapters this book covers. The first three chapters are considered “required reading” if you haven’t used Drupal before. The rest of the chapters will assume knowledge of the basics of Drupal, and the Views and CCK modules. If you’ve used Drupal 5 but haven’t yet used Drupal 6, you may also want to skim these chapters (particularly Chapter 3, as Views has changed significantly in Drupal 6).
- Chapter 1, Drupal Overview
This chapter answers the main “need to know” questions about Drupal: what’s Drupal, who’s using it, why are they using it, and how does it work? It also provides some historical context to Drupal, introduces essential terminology, and everything else you need to get up to speed.
- Chapter 2, Drupal Jumpstart
The first hands-on chapter hits the ground running, and will show you how to use Drupal’s core functionality, as well as a few contributed modules, in order to build a basic business website. By the end of this chapter, you should feel comfortable in Drupal’s administrative section, and also know how to create basic content through a WYSIWYG interface with the FCKeditor and IMCE modules. We’ll also discuss Drupal modules that can help handle inevitable abuse, including Mollom.
- Chapter 3, Job Posting Board
This chapter introduces the Content Construction Kit (CCK) and Views modules by walking through the construction of a job-posting website. By the end of this chapter, you’ll understand how to create custom content types and add form fields, as well as how to click together lists of any type of website content, which are the basis of all the other chapters in the book.
- Chapter 4, Product Reviews
In this chapter, you will build a community product review website, with the Amazon module providing the product data, and the Voting API and Fivestar modules providing a rating widget.
- Chapter 5, Wiki
This chapter covers several tools that can be used to create a wiki in Drupal, among other uses. The node revisions system (coupled with the useful Diff module), the Markdown filter for easy HTML entry, the Freelinking module to automatically create and link wiki pages, and the Pathauto module for automatically creating search engine-friendly URLs are all discussed in detail.
- Chapter 6, Managing Publishing Workflow
This chapter talks all about implementing custom publishing workflows with Drupal’s Actions system combined with the Workflow module, and the Views Bulk Operations and Workspace modules for creating custom administration screens.
- Chapter 7, Photo Gallery
This chapter helps you build a family photo gallery using the ImageField module, along with ImageCache to automatically generate sized thumbnails.
- Chapter 8, Multilingual Sites
This chapter describes how to build a multilingual site using the Locale, Content Translation, and Internationalization suite of modules.
- Chapter 9, Event Management
This chapter’s all about how to do event management in Drupal, featuring the Date and Calendar modules for storing and displaying event information, and the Flag module for keeping track of who’s coming.
- Chapter 10, Online Store
Use the powerful Ubercart suite of modules to build a T-shirt store that includes such features as a product catalog, shopping cart, and payment processing.
- Chapter 11, Theming Your Site
This chapter provides some overview information about Drupal’s theming system, and some basic tricks you can use to override the look and feel of Drupal. By reading this chapter, you can start modifying template files and start to give Drupal your own look and feel!
- Appendix A, Installing and Upgrading Drupal
If you’re new to Drupal, this appendix will get you up to speed on how to install it, as well as how to do upgrades down the road.
- Appendix B, Choosing the Right Modules
Evaluating modules is often the biggest hurdle to building a Drupal site. This appendix is a breakdown of strategies and tips for figuring out which module will work for your site.
- Appendix C, Modules and Themes Used in This Book
This appendix lists the modules and themes used in each chapter to re-create the hands-on sections.
Conventions Used in This Book
The following typographical conventions are used in this book:
- Italic
Indicates filenames, directories, new terms, URLs, and emphasized text.
Constant width
Indicates parts of code, contents of files, commands, and output from commands.
Note
This icon signifies a tip, suggestion, or general note.
Warning
This icon indicates a warning or caution.
Any navigation around Drupal pages is displayed as follows:
Administer→Site building→Modules (admin/build/modules). |
This is an instruction to click the Administer link in the navigation block, then Site building, then Modules. As a shortcut, you can also enter the path indicated in parentheses into your browser: http://www.example.com/admin/build/modules.
Using Code Examples
This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation.
All Drupal code, including the Drupal 6 code that you can access through the O’Reilly website (as described shortly) is subject to the GNU General Public License, version 2. Your use of Drupal code, including copying, modification, and distribution, is subject to the license. Also, “Drupal” is a registered trademark of the founder of the Drupal project, Dries Buytaert. Information about permitted uses of the code and the trademark can be found at the Drupal website (http://drupal.org), where you can also find information about how the GNU General Public License affects your use of the code. More information about the license is available at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html#SEC3.
With respect to other code examples in this book, you do not need to contact us for permission unless you’re reproducing a significant portion of the non-Drupal code. For example, writing a program that uses several chunks does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Using Drupal by Angela Byron, Heather Berry, Nathan Haug, Jeff Eaton, James Walker, and Jeff Robbins. Copyright 2009 Angela Byron, Heather Berry, Nathan Haug, Jeff Eaton, James Walker, and Jeff Robbins, 978-0-596-51580-5.”
If you think that your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com.
Downloading Drupal 6
This book’s website contains a link to a downloadable copy of of Drupal 6, along with all of the modules covered in the book, and the themes used in the example websites for each hands-on chapter at http://usingdrupal.com/source_code. Each hands-on chapter also has an “installation profile” (a set of starter scripts that configure default options) that bootstraps a starter site for each hands-on chapter. These installation profiles may be selected at the beginning of the Drupal installation process; for example, “Chapter 4: Job Posting.”
Switching between one chapter’s hands-on examples and another’s requires making a new site while using the same source code. You can do so with minimal fuss using the following steps:
Either create a new database for the chapter’s installation of Drupal, or delete and re-create the existing database.
Copy sites/default/default.settings.php to sites/default/settings.php, overwriting the existing settings.php file.
Change the permissions on sites/default/settings.php so that the file is writable.
Rerun the installation at http://www.example.com/install.php.
More information on how to install Drupal is available in Appendix A.
In addition to configuring some basic settings such as the site name, the theme, and so on, for each chapter, the installation profiles (with the exception of Chapter 2) also set up the following users:
- username: admin, password: oreilly
The first user, who is in the “site administrator” role; can do everything on the site
- username: editor, password: oreilly
A user in the “editor” role; used for chapters that require users with elevated permissions
- username: user, password: oreilly
A normal user in only the “authenticated user” role
It is these users the chapters refer to when the instructions reference logging in as the “editor” user, or similar. Unless otherwise specified, it is assumed that steps are completed as the “admin” user.
Safari® Books Online
Note
When you see a Safari® Books Online icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf.
Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com.
Comments and Questions
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc. |
1005 Gravenstein Highway North |
Sebastopol, CA 95472 |
800-998-9938 (in the United States or Canada) |
707-829-0515 (international or local) |
707-829-0104 (fax) |
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:
http://www.oreilly.com/catalog/9780596515805 |
To comment or ask technical questions about this book, send email to:
bookquestions@oreilly.com |
For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our website:
http://www.oreilly.com |
Acknowledgments
Team Lullabot would like to thank the book’s technical reviewers, including Robert Douglass, Ajay Gallewale, Jeffrey MacGuire, David Moore, and Matt Westgate. Thanks to Tatiana Apandi and Julie Steele from O’Reilly, who helped guide us through our first collective book authoring adventure. We’d also like to thank our business folks, Liza Kindred, Haley Scarpino, and Tim McDorman, for helping juggle schedules so that we could get this book completed. Jeff Eaton gets thanks for supplying photos for the image gallery chapter. Also, thanks to Lullabot’s Kent Bye for working his visualization mojo on the Views module, and John VanDyk for his extremely helpful feedback on some of the biggest chapters in the book. And a special thanks goes out to Ivan Zugec, who graciously transferred ownership of the http://usingdrupal.com domain to us. And of course thanks to Dries Buytaert for inventing and open-sourcing Drupal; without him, none of this would have happened.
Angela Byron would first like to give a huge shout-out to her wife, Marci McKay, who was tremendously patient and understanding with all the late nights, and is in general extremely tolerant, even supportive, of Angie’s insatiable Drupal obsession. A huge thanks also to her family—in particular, her mom and dad, Jeanne and Mike, and her siblings, Keith and Sara, for their support through the authoring process. John Wait and Debra Williams-Cauley also deserve thanks for their part in helping Angie realize her dream of authoring a book. Michelle Cox and Matthew Harrison helped provide early “sanity checks” for the book outline. Moshe Weitzman, Brandon Bergren, and Dries Buytaert provided technical review of some early versions of chapters, and Dries in particular offered thoughtful input and support throughout.
Addison Berry would like to thank her partner, Colleen McGraw, who was extremely patient about the lost weekends and neglected house chores, for pushing Addi onward when mired, and being an inspiration through all the ups and downs of life. Richard Burford, Alex Dergachev, Joel Farris, Jay McDonald, Don Palmer, Jose Reyero, and Brian Vuyk graciously gave feedback on her chapters, and Wim Leers supplied an emergency Dutch translation. The entire Drupal community has been amazingly supportive in her Drupal journey and of this book. None of this would have happened were it not for them. Lastly, thanks to my parents, Joan and Merlin Berry, for supporting all of the crazy things she’s done in her life and never failing to believe in her.
Nathan Haug would like to thank his amazing parents, James and Aleda Haug, as well as his inspirational grandfather, Tom Arnberg. Thanks go to his technical reviewers, David Moore and John VanDyk. Extra thanks go to all of the authors of the Drupal platform and add-on modules. Nate thanks Earl Miles for Views and Jonathan Chaffer, Karen Stevenson, and Yves Chedemois for CCK. The Drupal platform would never be what it is without the amazing cooperation between so many individuals.
Jeff Eaton would like to thank his wife, Catherine, for her deep well of patience and encouragement. Romantic dinners should not include module testing and troubleshooting, and Catherine’s good humor when technology intruded was instrumental in seeing this project through. Doug Green, Earl Miles, and countless other members of the Drupal community gave excellent feedback and pointed out complexities that could easily trip up new users. Jason Scott and Jeff Benson provided endless late-night and early-morning commiseration, and Jeff’s parents, Doug and Cindi, spent the better part of two decades encouraging his geeky adventuring.
James Walker would like to thank his two children, Andrew and Camryn, for their love, patience, and trips to the park. Karen Stevenson, Ryan Szrama, Earl Miles, and Nate Haug provided code that made his chapters possible and were extremely helpful in answering questions and providing insight. Thanks to his mom, Linda, who has always believed in him and who has always provided excellent housing for Lullabot retreats.
Jeff Robbins would like to thank his wife, Jennifer Niederst Robbins, for her love, support, and copyediting prowess, and his son, Arlo, for reminding him to keep things fun. Thanks to O’Reilly Media, which has felt like an extended family since the early 1990s, when he and Jennifer worked and met there. Jeff would like to thank Matt Westgate for being the best business partner he could imagine and for providing the stable, serene, and happy atmosphere in which Lullabot, the company, and Lullabot, the individuals, have thrived. Jeff also sends thanks and appreciation to Liza Kindred, for keeping the company running; to the rest of the team, for keeping him constantly amazed; and to the Drupal community at large, for all of the generous and astounding code that we call Drupal.
Get Using Drupal now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.