Tải bản đầy đủ (.pdf) (494 trang)

using drupal

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (25.44 MB, 494 trang )

Using Drupal
Angela Byron, Addison Berry, Nathan Haug, Jeff Eaton,
James Walker, and Jeff Robbins
Beijing

Cambridge

Farnham

Köln

Sebastopol

Taipei

Tokyo
Using Drupal
by Angela Byron, Addison Berry, Nathan Haug, Jeff Eaton, James Walker, and Jeff Robbins
Copyright © 2009 Angela Byron, Heather Berry, Nathan Haug, Jeff Eaton, James Walker, and Jeff Rob-
bins. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (). For more information, contact our corporate/
institutional sales department: (800) 998-9938 or
Editor: Julie Steele
Production Editor: Loranah Dimant
Copyeditor: Nancy Kotary
Proofreader: Sada Preisch


Indexer: Fred Brown
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
Printing History:
December 2008: First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Using Drupal, the image of a dormouse, and related trade dress are trademarks of
O’Reilly 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 O’Reilly 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 con-
tained herein.
TM
This book uses RepKover™, a durable and flexible lay-flat binding.
ISBN: 978-0-596-51580-5
[M] [3/09]
1235668217
Table of Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
1. Drupal Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
What Is Drupal? 1
Who Uses It? 2
What Features Does Drupal Offer? 3
A Brief History of Content Management 4
A Historical Look at Website Creation 4
The Age of Scripts and Databases 6

The Content Revolution 7
How Does Drupal Work? 8
Modules 10
Users 10
Content (Nodes) 11
Ways of Organizing Content 13
Types of Supporting Content 14
Getting Help 15
Conclusion 16
2. Drupal Jumpstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Case Study 18
Implementation Notes 19
Spotlight: Content Management 20
Content 20
Comments 24
Navigation 25
Blocks 27
Hands-On: Content Management 28
Creating Content 29
Managing Site Navigation 32
iii
Configuring Blocks 34
Spotlight: Modules 36
Module Administration Page 37
Finding and Installing Modules 38
Removing Modules 40
Hands-On: Working with Modules 40
Path Module 41
Administration Menu Module 42
Spotlight: Access Control 45

Configuring User Access 46
User Profiles 48
User Settings 49
Handling Abusive Users 50
Hands-On: Creating Roles 50
Hands-On: Configuring Permissions 52
Hands-On: Contact Form 56
Spotlight: Taxonomy 59
Hands-On: Blog 61
Spotlight: Content Moderation Tools 67
Automated Spam Detection Tools 67
Manual Content Moderation Tools 69
Spotlight: Themes 69
Finding a Theme 69
Theme Installation 70
Theme Configuration 70
Blocks and Regions 73
Administration Theme Setting 74
Hands-On: Branding the Site 74
Spotlight: Content Editing and Image Handling 76
Content Editing 76
Image Handling 77
Spotlight: Input Formats and Filters 79
Hands-On: Setting Up FCKeditor 82
Summary 89
3. Job Posting Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Case Study 92
Implementation Notes 92
Spotlight: CCK 94
Fields 95

Widgets 96
Formatters 97
Hands-On: CCK 98
iv | Table of Contents
Hands-On: Job Content Type 100
Hands-On: Customizing Field Display 105
Hands-On: Job Application Type 108
Spotlight: Views Module 112
Displays 114
Pieces of a View 118
Hands-On: The Views Module 120
Jobs View 121
Job Applications View 134
Taking It Further 147
Summary 147
4. Product Reviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Case Study 150
Implementation Notes 151
First Steps: Basic Product Reviews 153
Creating the Product Review Content Type 153
Spotlight: Amazon Module 156
What’s Included? 156
Locale 157
Referral Settings 158
Hands-On: Adding an Amazon Field 158
Adding the Product Field 158
Finding Product IDs 160
Spotlight: Voting API and Fivestar 161
Hands-On: Adding Ratings 162
Adding the Rating Field 163

Turning on Visitor Ratings 164
Hands-On: Building a Product List 166
Spotlight: The Search Module 170
The Importance of Cron 170
Searching with Views 172
Hands-On: Make the Product List Searchable 172
Spotlight: CSS Injector 175
Hands-On: Polishing the Presentation 175
Setting CCK Display Fields Options 176
Configuring CSS Injector 177
Taking It Further 177
Summary 179
5. Wiki . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Case Study 182
Implementation Notes 183
Table of Contents | v
Wiki Functionality 183
Easy Text Formatting 183
Easy Linking 184
Tracking Changes 184
Human-Readable URLs 185
Listing Changes 185
Hands-On: First Steps 185
Creating a Wiki Content Type 185
Removing the Author Information Display 187
Configuring Access Permissions 187
Hands-On: Wiki Input Format 187
Configuring the Filters 188
Creating the Wiki Input Format 189
Setting Up Format Permissions 191

Adding Content 191
Spotlight: Pathauto 194
Hands-On: Pathauto 196
Configuring Settings 197
Spotlight: Drupal’s Revision Tracking 199
Hands-On: Revisions and Diff 200
Make Revisions the Default 200
Setting Permissions 200
Viewing Revisions and Reverting 200
Using Diff 201
Hands-On: New Pages and Recent Edits with Views 202
Recent Posts Listing 203
Recent Edits Listing 205
Taking It Further 207
Summary 208
6. Managing Publishing Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Case Study 212
Implementation Notes 213
Hands-On: First Steps 214
Spotlight: Actions and Triggers 215
Hands-On: Actions and Triggers 217
Configure Actions 217
Assign Triggers 219
Spotlight: Workflow Module 220
Hands-On: Creating a Workflow 222
Spotlight: The Workspace Module 226
Hands-On: Create Workspaces 227
Spotlight: Views Bulk Operations 228
vi | Table of Contents
Hands-On: Building an Administration Page 229

Create Workflow Actions 230
Configure the View 230
Taking It Further 232
Summary 233
7. Photo Gallery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Case Study 236
Implementation Notes 236
Photo Uploads 237
Thumbnail Generation 237
Photo Galleries 237
Spotlight: ImageField 237
Configuration 238
Hands-On: Uploading Photos 240
Photo Content Type 240
Image Galleries 243
Spotlight: ImageCache 246
Presets and Actions 246
Using a Preset 251
Troubleshooting ImageCache 253
Hands-On: ImageCache 255
Create ImageCache Presets 255
Configure Photo Field Display 257
Improve Image Quality 258
Hands-On: Gallery View 259
Hands-On: Latest Photos Block 264
Hands-On: Custom Pagers 266
Taking It Further 269
Summary 270
8. Multilingual Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Case Study 272

Implementation Notes 273
Forum Discussions 273
Knowledge Base 273
Translating User Interface Text 273
Translating User-Generated Content 274
Spotlight: Core Internationalization Features 274
Locale 275
Content Translation 279
Hands-On: Installing a Translation 280
Hands-On: Configuring Locale Features 284
Table of Contents | vii
Language Negotiation Settings 284
Language Switcher 285
Hands-On: Translatable Content 286
Spotlight: Localization Client 287
Hands-On: Translating the Interface 288
Using the Locale Module 288
Using the Localization Client 291
Hands-On: Translating Content 293
Translation 293
Spotlight: Internationalization 296
Content Selection 297
Strings 298
Site-Wide Language-Dependent Variables 298
Module Helpers 299
Synchronization 300
Hands-On: Internationalization Features 300
Content Selection 300
Site-Wide Variables 301
Content Types 304

Taxonomy 307
Taking It Further 309
Summary 310
9. Event Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Case Study 314
Implementation Notes 314
Event Management 314
Attendance Tracking 315
Hands-On: First Steps 316
Creating an Event Content Type 316
Access Control 317
Spotlight: Date Module 318
Date API Module 318
Date Timezone 318
Date Field Types 319
Date Widgets 319
Date Settings 320
Hands-On: Adding Dates 325
Set Up the Date Module 325
Add the Date Field 325
Hands-On: Upcoming Events View 327
Spotlight: Calendar Module 330
Calendar View Type 331
viii | Table of Contents
Hands-On: Calendar View 331
Spotlight: Flag Module 334
Hands-On: Flag Configuration 335
Hands-On: Attendee View 336
Taking It Further 338
Summary 339

10. Online Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Case Study 342
Implementation Notes 342
Spotlight: Ubercart Packages 343
Ubercart—core 344
Ubercart—core (optional) 346
Ubercart—extra 350
Spotlight: Ubercart’s Administration Panel 350
Hands-On: Setting Up the Store 353
Initial Setup Tasks 353
Spotlight: Products, Product Classes, and Attributes 354
Hands-On: Creating Products 357
Initial Setup Tasks 357
Configuring Product Classes 358
Configuring Product Attributes 359
Configuring Product Settings 362
Configuring the Catalog 362
Spotlight: The Ordering Process 366
Hands-On: Processing Orders 368
Shopping Cart 369
Taxes 370
Shipping 370
Payment 371
Placing a Test Order 372
Fulfilling an Order 375
Access Control 377
Taking It Further 378
Summary 379
11. Theming Your Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Spotlight: The Theme System 382

.info Files 384
Regions 385
Features 386
CSS 387
JavaScript 387
Table of Contents | ix
Template Files 388
The template.php File 390
Hands-On: Creating a Custom Theme 393
Make a Copy of the Theme 394
Changing CSS 396
Spotlight: Template Files 397
Hands-On: Working with Template Files 398
Modifying a Template File 398
Theming Specific Content Types 403
Overriding a Module’s Template File 404
Creating a New Region 407
Spotlight: Advanced Overrides 408
Template Variables 408
Theme Functions 409
Hands-On: Using template.php for Overrides 411
Overriding a Template Variable 411
Overriding a Theme Function 412
Taking It Further 414
Summary 415
References 416
A. Installing and Upgrading Drupal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
B. Choosing the Right Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
C. Modules and Themes Used in This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457

x | Table of Contents
Foreword
Drupal’s modular architecture and open source nature make it a popular PHP appli-
cation 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 6 release and even more are responsible for developing and maintaining more
than 2,000 contributed modules that can be used to extend Drupal’s functionality.
The size, passion, and velocity of the Drupal community, combined with Drupal’s
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 cre-
ated to catch up with the latest trends on the Web or to invent completely new para-
digms, 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, wikis, job posting boards, conference websites, and more.
Unfortunately, the challenge for many of these site administrators, and even seasoned
Drupal developers, is to try and 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 explaining how to rapidly assemble a wide variety of websites
using some of Drupal’s most commonly used modules. Whether you’re new to building
websites or an experienced programmer, this book is full of useful information. I prom-
ise that by the end of this book, you’ll be much more prepared to build the Drupal site
of your dreams.
—Dries Buytaert

Drupal founder and project lead
July 2008
xi

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 prac-
tices 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 hard-
core, 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 () or MAMP for Macs (o).
xiii
Visit for a list of Drupal-friendly web hosting companies, and
visit 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 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 con-
stantly 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 (http://
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 com-
paring 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 spe-
cific requirements.
xiv | Preface
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 fea-
tures 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 addi-
tional 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 every-
thing 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.
Preface | xv
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.
xvi | Preface
Appendix B, Choosing the Right Modules
Evaluating modules is often the biggest hurdle to building a Drupal site. This ap-
pendix 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.
This icon signifies a tip, suggestion, or general note.
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 paren-
theses into your browser: />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
Preface | xvii

trademark can be found at the Drupal website (), 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 />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. Sell-
ing or distributing a CD-ROM of examples from O’Reilly books does require permis-
sion. 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 Rob-
bins, 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
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 Each hands-on chap-
ter also has an “installation profile” (a set of starter scripts that configure default op-
tions) 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:
1. Either create a new database for the chapter’s installation of Drupal, or delete and
re-create the existing database.

2. Copy sites/default/default.settings.php to sites/default/settings.php, overwriting the
existing settings.php file.
3. Change the permissions on sites/default/settings.php so that the file is writable.
4. Rerun the installation at />More information on how to install Drupal is available in Appendix A.
xviii | Preface
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 com-
pleted as the “admin” user.
Safari® Books Online
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 .
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:
/>To comment or ask technical questions about this book, send email to:

Preface | xix
For more information about our books, conferences, Resource Centers, and the
O’Reilly Network, see our website:

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 visuali-
zation 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 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 sup-
portive 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,
xx | Preface
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 trouble-
shooting, 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.
Preface | xxi

CHAPTER 1
Drupal Overview
This book will show you how to build many different types of websites using the Drupal
web publishing platform. Whether you’re promoting your rock band or building your
company’s intranet, some of your needs will be the same. From a foundational per-
spective, your site will have content; be it audio or text or animated GIF images, a
website communicates its content to the world. You will also need to manage this
content. Although it’s possible to roll your own system with enough knowledge of the
underlying web technologies, Drupal makes creating your website; adding new fea-
tures; and day-to-day adding, editing, and deleting of content quick and easy. And
finally, your website will have visitors, and this book will show you many different ways
in which you can engage and interact with your community using Drupal.
This chapter will begin by providing the hard facts about Drupal: what it is, who uses

it, and why they chose it. It will then dive into a conceptual overview, starting with
what this ambiguous term “content management” actually means, and how we arrived
at building websites this way. And finally, we’ll define and explain the core Drupal
concepts that are necessary to understand how Drupal handles its content.
What Is Drupal?
Drupal is an open source content management system (CMS) being used by hundreds
of thousands of organizations and individuals to build engaging, content-rich web-
sites.
*
Building a website in Drupal is a matter of combining together various “building
blocks,” which are described later in this chapter, in order to customize your website’s
functionality to your precise needs. Once built, a Drupal website can be maintained
with online forms, and without having to change code manually. Drupal is free to use;
it has an enormous library of constantly evolving tools that you can use to make your
website shine.
*
For more on the open source software movement, please see —which, incidentally, is
also a Drupal site.
1

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×