Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover
Title Page
Copyright
Dedication
Contents at a Glance
Contents
Foreword
About the Authors
About the Technical Reviewer
Acknowledgments
Preface: Why Drupal?
What's New in Drupal 7
How to Use This Book
How Drupal Works
Part 1: Getting Started
Chapter 1: Building a Drupal 7 Site
Planning: Setting Parameters and Knowing Where You're Going
Discovery: Why Should This Site Be Built?
Information Architecture: Exactly What Will You Build?
Design
Implementation
Installing Drupal
Drupal's Administration Menu
Appearance: Changing a Core Theme's Color Scheme
Extending Functionality with Modules
Allowing People to Register and Log In with OpenID
Creating Content Types and Adding Content
Creating Content
Blocks: Creating a Mission Statement
Taxonomy: Categorizing Content
Users, Roles, and Permissions
Time for a Celebratory Beverage
Chapter 2: Essential Tools: Drush and Git
A Beginner's Guide to Installing Drush
Git: Development Grease
Why Git?
Installing Git
Working with Git
Other Useful Git Commands
Database Backup Tools
Summary
Part II: Site Building Foundations
Chapter 3: Building Dynamic Pages Using Views
What Are Views?
Examples of Views Usage
Download, Enable, and Configure Permissions for the Views Module(s)
The Views Administration Page
Advanced Help Module
Action Links
Change Which Available Views Are Listed
Available Views
Deconstructing a View
Display Types
Views Configuration Detail
Overriding: A Views Concept
Understanding What Type of Content Will Be Output: Views Filters
Advanced Filter Criteria Groups: Combining Sorts with Logical Operators
Understanding the Order in Which Content Will Be Output: Views Sort Criteria
Understanding What Pieces of Content Will Be Output: Views Format Settings
Creating a Basic View
The Goal
Systematic Approach
Set Up the Basics for Your Views
Define the Administrative Information
Define the Title
Define What Type of Content You Want to Display
Define What Elements of the Content You Want to Display
Define Format Settings
Define the Order in Which You Want Your Content to Display
Define the Number of Results
Add a Menu
Define Advanced Settings
Preview Your Work
Dynamically Editing Your View
Admire Your View
Add More Features
Extend a View
Handling the Use Case of Zero Results
One Page, Multiple Displays to Highlight First Result
Using Tabs for Unique Displays
Cloning and Making Administrative Tables Using Exposed Filters
Advanced Views Implementations
Contextual Filters
Relationships
Other Modules
Exporting to Code
Additional Resources
Chapter 4: There's a Module for That
Modules for Drupal Are Constantly Evolving
Fewer Modules Is Better
How to Find and Choose a Module
What to Do When Something's Wrong with a Module
Modules in Core
Where to Store Contributed Modules
Site Building Essentials
Views
Pathauto
Token (Dependency)
Additional Field Types
WYSIWYG
Webform
AntiSpam or Mollom
Other Modules That May Prove Useful
Administrative Interface and Content Entry
Content Display
Menus and Navigation
Community Building and Social Networking
Paths, Search and 404 Errors
Miscellany
The Beauty of It All
Chapter 5: Creating Community Web Sites with Organic Groups
Installing and Configuring Organic Groups
Group Content Types
Creating Groups
Using Views with Organic Modules
Creating Group Content
Getting Started with Panels
Members, Roles, and Permissions
Summary
Chapter 6: Security in Drupal
Setting Up a Secure Drupal Site
Use Strong Passwords
Reserve User 1 for Administration Purposes Only
Be Cautious When Assigning Permissions
Keep Text Formats Tight and Secure
Avoid Using the PHP Filter Module
Security Process
Choosing Modules and Themes: How Secure Are Contributed Projects?
Keep Your Code Base Current
Writing Secure Code
Dealing with Security Issues
Summary
Chapter 7: Updating Drupal
Why Update
Preparation
Manual Update
Follow the Steps in UPGRADE.txt
Drush Update
Diff Update
Contributed Modules
Drupal's Automated Module Installer
Updating Modules with Drush
Summary
Chapter 8: Extending Your Site
Showcasing Authors with Profile Pages
Giving Authors a Headshot Image
Linking from Profiles to Web Sites
Authors' Other Homes on the Internet
A Non-displaying Data Field: Approximate Pages
Connecting Author Profiles to Authors' User Accounts
Giving Authors Permission to Create Profiles
Listing the Authors
Building the Authors Headshot View
Building an Author Biographies View Page, Reachable As a Tab on the Authors View
Fine-tuning Content Display
Using View Modes to Display the Same Content in Different Ways
Modifying Teaser Display and Setting Trim Length
Making the Table of Contents with Book Module
Setting Permissions for Organizing and Writing Chapters
Adding Metadata to the Chapter Content Type with Fields
Setting How the Chapter Content Type Displays Its Fields
Using Menu Block to Display a Better Table of Contents
Adding the Table of Contents to the Main Menu
Linking Chapters to Their Authors
Adding a Resource Content Type That References Chapters
Reusing Chapter's Image Field
Allowing People to Attach Generic Files to Content
Connecting Content Types with a Node Reference
Managing Resource Content Type Display
Showing Content That References the Post Being Viewed
Giving Faces to the People Posting on Your Site
Adding a Text Format That Allows Images
Bonus: Making It Easy to Insert Images into Posts
Limiting Access to the Suggestion Status Field
Autogenerating Human-readable URLs with Pathauto
Summary
Part III: Making Your Life Easier
Chapter 9: Drupal Community: Getting Help and Getting Involved
How to Get the Most from Your Participation
Where to Find the Community
Reading, Listening, and Watching
IRC
The Issue Queues
Summary
Chapter 10: Planning and Managing a Drupal Project
The Role of Limitations
Putting Down Your Concept on Paper
1. Discovery
2. Information Architecture
3. Design
4. Development and Implementation
5. Content
6. Deployment/Launch
7. Maintenance
Project Management Methodologies and Drupal
Taking the Lifecycle into Account on Paper
What's a Project Plan?
Estimating Completion Dates
Risks
Minimum Viable Project/Product
Keeping Track of Commitments
Project Manager Tasks Beyond Development
Kickoff Meetings
Discovery Meetings
Information Architecture/Design Meetings
Development Meetings
Checkins
Milestone Closing Meetings
Launch Meetings
Post-Project Debriefs
Other Tasks for Project Managers
Creating User Stories
Implementing Tasks and Task Workflow
Tasks That Make up Milestones
Bad Days
Further Resources
Chapter 11: Documenting for End Users and the Production Team
What Makes Good Documentation?
Getting Clients into Content Entry Early
Creating End-User Documentation Post-Launch
The Anatomy of Good Client Documentation
Documenting for the Development Team
Documenting for the Community
The More You Know
Chapter 12: Development Environment
Starting with Quickstart
Enhancing Your Existing Dev Environment
Hosting Your Site Locally
Accessing the Command Line
Working with Rendered HTML, CSS, and JavaScript
Browser and Device Compatibility Testing
Working with PHP Files
The Most Basic Development Environment
Select Hosting Service
Uncompressing Archives
Server-Side Tasks and Tools
Summary
Chapter 13: Putting a Site Online and Deploying New Features
Putting Your Site Online
1. Export the Database
2. Transfer to Server
3. Create a Database on the Server and Import Your Database
4. Set the Database Settings in settings.php
5. Point Incoming Traffic for Your Domain(s) to Your Site on the Server
Before You Go Any Further, Back Up
Staging and Deployment
Approach
The Workflow
Bringing Content from Production to Development (and Stage/QA)
Bring Code Changes from Development to Stage, then Live
How to Put “Everything In Code”
Development Workflow Recap
Summary
Chapter 14: Developing from a Human Mindset
Use Revision Control
Backup
Experiment Freely
Contribute
Part IV: Front-End Development
Chapter 15: Theming
The Core Themes Directory
Core Themes
Theme Engines
Theme Administration
Enabling and Setting a Default Theme
Administration Theme
Global Theme Settings
Installing a New Theme
Defining Theme Metadata (.info Files)
Required Properties
Additional Properties
Working with Regions
Default Regions
Hidden Regions
Module-Specific Regions
Regions and Your Theme
Using Regions vs. Hard-coding Variables in Template Files
Layout Strategies
Template Files
Common Core Templates
Overriding Template Files
Global Template Variables
Theme Functions
How Theme Functions Are Created
Calling Theme Functions
Overriding Theme Functions
Theme Hooks and Theme Hook Suggestions
What Is a Theme Hook?
Theme Hook Suggestions
Suggestions and Template Files
Suggestions and Theme Functions
Summary
Chapter 16: Advanced Theming
Finding Available Variables in the Theme Layer
Using the Theme Developer Module
Preprocess and Process Functions
Implementing Preprocess and Process Hooks
Finding the Contents of $variables
Preprocess Functions in Action
Using the Render API
What Is a Render Array?
Identifying Render Elements
Manipulating the Output of Render Elements
Notable Render Arrays in Core Templates
Introducing render(), hide(), and show()
Theming Forms
How Form Markup Is Generated
First Steps for Theming Forms
Theming Forms with Theme Functions
Theming Forms with Template Files
Modifying Forms Using Alter Hooks
Managing CSS Files
Aggregation and Compression
Patterns and Naming Conventions
Adding, Removing, and Replacing CSS Files
Working with Base and Subthemes
Creating a Subtheme
Inheritance and How It Works
Finding a Good Base Theme
Tips for Creating Your Own Base Themes
Sustainability and Best Practices
Start With a Good Base
Override Template Files with Purpose
Leverage Default CSS Classes
Do My Changes Belong in a Module?
Summary
Chapter 17: jQuery
Implementing jQuery and JavaScript
Including JavaScript
JavaScript Libraries
Overriding JavaScript
Drupal Behaviors
Degrading JavaScript/jQuery Nicely
jQuery UI
jQuery UI in Drupal Core
Further jQuery Resources
Summary
Part V: Back-End Development
Chapter 18: Introduction to Module Development
A Very Simple Module
Two Files in a Folder
Where to Put a Custom Module
Create a Repository for Your Module
The .info File
The .module File
Hooks
Technical Skills
PHP Basics
Terminology
Operators and Conditional Statements
Control Structures
Drupal Coding Standards
Development Tip #1: When Something Isn't Working, Clear Caches
Development Tip #2: When Anything's Missing, Check Permissions
Development Tip #3: Set Your Site to Show All Errors
Summary
Chapter 19: Using Drupal's APIs in a Module
Altering Forms
Localization with t() and format_plural()
Finding a Drupal Function That Does What You Need
Investigating What the Function Gives You
Creating a Page with hook_menu()
Choosing a Path for an Administration Page
Defining a Page with a Normal Menu Item
Defining a Tab with a Local Task Menu Item
Declaring Menu Items for X-ray Module
Using Existing Permissions in Your Module
Finding Permissions' System Names in the Database
Finding Permissions' System Names in Code
A Second Local Task to Complement the Default Local Task
Call All Implementations of a Hook
Format Data for Display as a Table
Documenting Themeable Code with @ingroup themeable
Making Modules Themeable
Resources for Theming in Modules
A More Drupal 7 Approach: Leveraging the Power of Render Arrays
Calling a Drupal Function Directly
Styling Your Module: Adding a CSS File
Database API
Fetching Data with a Select Query
Fetching Data with a Static Query with a Join on Two tables
A Non-Database Interlude: Displaying the Same Data in Two Locations
Using variable_get() and Another Static Select Counting and Grouping Query
Dynamic Queries
The .install File
Figuring Out Your Data Model
Creating a Database Table
Inserting and Updating Data
Displaying Data in a Sortable Table
Drupal Entities: Common Structure Behind Site Components
Summary
Chapter 20: Refining Your Module
Creating a Configuration Page for Your Module
Building a Settings Form
Defining New Permissions
Conditionally Taking Action Based on Configuration or User Access
Writing a Utility Function when Drupal APIs Miss Your Need
Listing Data as Human-Readable, Properly-Punctuated Text
Making Mistakes and Embracing Error Messages
Searching for Answers
Syntactic Fatal Errors
Runtime Fatal Errors
Tracking Down the Cause of Errors and Warnings
Making a Preprocess Function
Final Considerations
Coder Module Review
Peer Review
Using hook_help() as Drupal Intended
Summary
Chapter 21: Porting Modules to Drupal 7
Deciding to Upgrade a Module
Posting the Issue
Why Not Custom Code?
Undertaking the Upgrade
Keeping Track of What You Need to Know
Automating (Part of) the Module Upgrade
Identifying What's Wrong
Finding Models to Follow
Contributing the Upgrade to Drupal.org
Chapter 22: WritingProject-Specific Code
Custom Modules
Hooks
The Method
What is it that I need to modify and why am I doing it?
Where can I hook into?
What is already there?
How can I modify existing functionality for my own needs?
An Example: Changing the Label of a Submit Button
Specific Use Cases
Hiding Elements from the User Interface
Execution Order of Hooks
Working with Fields
Adding Dynamic Front-End Interaction
Making Code Reusable
Make Functionality Configurable
Tie Components Together
Document Your Code
Follow Drupal's Coding Standards
Release Your Work
Summary
Chapter 23: Introduction to Functional Testing with Simpletest
Advantages (and Caveats) of Using Simpletest
When to Use Simpletest
What Is Test-Driven Development (TDD)?
How Simpletest Works
Setting up and Running a Test
Anatomy of a .test File
Writing Your First Test
Running Your First Test
Simpletests and Forms
The Simpletest API and Further Reading
Submitting a Patch to Drupal.org
Summary
Chapter 24: Writing a Major Module
How Not to Build a Module
Know the Tools Drupal Gives You
Should Your Module Provide an API?
Keep API and UI Separate
Use APIs to Hide Complexity
Making Your Module Modular
Unleashing the Power of Hooking Into Your Module
Progressive Enhancement: Making Use of Other Modules If They Are Enabled
Getting Started with a Test Environment
Stealing Some Code to Start
Sharing Your Code in a Sandbox on Drupal.org
Planning Your Approach
Outlining an API
Diving Into Doing
Defining Your Data Model
How to Store the Data and How to Edit It in the UI
Providing a New Entity Type
When to Create an Entity Type
How to Create an Entity Type
Defining an Entity Access Callback Function
Giving Your Entities an Administrative Interface
Programmatically Creating and Attaching Fields
Finding a Model
Define Done
Part VI: Advanced Site-Building Topics
Chapter 25: Drupal Commerce
Drupal Commerce Overview
Key Features
Digging Into Drupal Commerce
Commerce
Price
Dynamic Pricing
Product
Line Item
Product Reference
Building a Product Display Node Type
Customer
Order
Payment
Enabling Payment Methods
Checkout
Cart
Summarizing the Main Components
Implementing Drupal Commerce
Development History
Design Philosophy
Development Standards
Building on Drupal 7
Core Entities and Fields
Forms API Improvements
Contributed Module Dependencies
Summary
Chapter 26: Drush
Getting Started with Drush
Drupal Site Selection in Drush Commands
Drush Alias Files (aliases.drushrc.php)
Using the Drush Shell
Applying Code Updates with Drush
Installing Drush Extensions
Going In-Depth with Drush Configuration Options and Aliases
Drush Contexts
Command-Specific Options
Site Lists
Using Remote Commands to Deploy Sites with Drush
Setting Up an SSH Key Pair
Making a Local Copy of a Remote Drupal Site
Managing Dump Files
Using sql-sync Without Installing Drush on the Remote System
Using the Drush Site Context to Control sql-sync Options
Scripting with Drush
Processing Script Command Line Arguments and Options
Running External Commands
Processing Invoke Process Results
Output and Logging
Prompting the User
Logging and Error Reporting
Writing Drush Extensions
The Drush Command Hook
Providing the Command Implementation Function
Return an Array to Pass Structured Data to Other Drush Scripts
Manually Specify the Command Function with a Callback Item
Placing the Command Implementation in a Separate File
The Drush Help Hook
Altering Drush Command Behavior
Summary
Chapter 27: Scaling Drupal
Do You Need to Care About Scaling?
Cache
Disabling Caching During Development
memcached
Varnish
On Databases
Indexes
NULL in SQL
A CAP Between ACID and BASE
MongoDB
Watchdog, Session, and Queue
Null Values in MongoDB
Summary
Chapter 28: Spice Your Content Up With Tasty Semantics
Information Overload
How Did We Get There?
Decentralized Dataspaces
Linking Data at the Global Web Scale
Do You See What I Mean?
RDFa, or How HTML Can Be Augmented with Semantics
RDFa, Microformats andMicrodata
Drupal 7 and the Semantic Web
Understanding the Structure of RDF Mappings
Working with RDF Mapping Structures
RDF Vocabularies in Drupal 7
Using RDF Beyond Drupal Core with the Contributed Modules
Summary
Chapter 29: The Menu System and the Path Into Drupal
Drupal’s Menu System by Example
The Never-ending Path
Structure of a Path
Callback Functions
Loader Functions
Fitness
Modifying Existing Router Items
Summary
Chapter 30: Under the Hood: Inside Drupal When It Displays a Page
Bootstrap
First Bootstrap Phase: Initialize Configuration
Second Bootstrap Phase: Try to Serve a Cached Page
Third Bootstrap Phase: Initialize the Database Layer
Fourth Bootstrap Phase: Initialize the Variable System
Fifth Bootstrap Phase: Initialize Session Handling
Sixth Bootstrap Phase: Set up the Page Header
Seventh Bootstrap Phase: Find out the Language of the Page
Final Bootstrap Phase: Load Modules and Initialize Theme
Execution of the Page Callback
A Typical Example
Summary
Chapter 31: Search and Apache Solr Integration
Search Module Administrative Options
Search Results and Facet Blocks
Search Module API
Hooks Implementations Required to Create a Search
Additional Search Module Hooks
Apache Solr Search Configuration
Enabled Filters
Type Biasing and Exclusion
Apache Solr Search Customization
Hooks for Getting Data into Solr
Hooks for Altering Queries and Results
Integrating with the Apache Solr Server
Managing Data in the Solr Index
Searching and Analysis
Summary
Chapter 32: User Experience
Modularity
Human API
Memory
Long Term Memory
Mental Model
Perception
Gestalt Psychology
Law of Similarity
Law of Proximity
Color
Color Harmony
Practice
The Process
The Challenges
Concept: What Exactly Are You Building?
Wireframes
Build: Build an Alpha and Verify with Users
Optimize: Observations and New Versions
Running the Usability Test
Analysis of Results
Reporting of Issues
Feedback from Issue Queues
Release: Project Page and Documentation
Copywriting
Causes of Unhelpful Copy
Principles
Chapter 33: Completing a Site: The Other 90%
Creating a View Mode
Creating a Custom Theming Template
Modifying the Chapter Number Field's Display
Linking to Drupal.org and Twitter Accounts with Field Formatters
Fetching the Username
Caching Simple Data Using Drupal's Default Cache Table
Streamlining an Awkward Form Element with CSS
Contextual “Add New” Links for Content Types
Finding and Following a Model
Noticing and Adopting a Better Way
Making a Custom Text Filter
Looking for a Module that Does What You Need
Choosing an Approach
Finding an Example (Hint: the Examples Project)
Giving a Module an Interim Name
Start a Repository for Your Module
Making the Tags and Replacement Markup Form
Making Your Own Hook
Filtering the Content
Renaming Your Module
Conditionally Including a Stylesheet for an Administration Page
Adding a Container Form Element with a Specified Class
Sharing Your Module on Drupal.org
Coda on a Contributed Module
Making a Site-Specific Module that Uses Your API
The Payoff
Adding Custom Markup for Output
Making Next and Previous Links That Mimic Book Navigation
Pulling the Information
Creating a View to Make User Pages Have Hackable URLs
In Conclusion
Chapter 34: Drupal Distributions and Installation Profiles
Site Templates
Full-Featured Services
Development Profiles
An Example Distribution: Drune
Creating Installation Profiles
Structure of an Installation Profile
Dealing with Configuration: Features
Using Installation Profiles and Features as a Development Tool
Packaging Your Code
Drush Makefiles
Hosting on drupal.org
Packaging
The Future of Distributions
Summary
Part VII: Drupal Community
Chapter 35: Drupal’s Story: A Chain of Many Unexpected Events
The Original Accident
Drupal Gains a Foothold
The Extended Weekend from Hell
If You Have a Problem, Please Search Before Posting a Question
The Story Continues
Chapter 36: Now You’re in Business: Making a Living with Drupal
Building a Drupal Site: New Rules for New Technologies
“I Hate Drupal:” Things That Can Go Wrong
Understanding Drupal
Building on Drupal
Ensuring Your Success
Building Your Drupal Career
Finding Your Place
Getting Yourself Out There
Out on Your Own: Building a Drupal Business
Building a Drupal Career
Building Drupal: Making a Living as a Contributor
Benefits of “Giving Back”
Sustainability Counts!
Potential Business Models
Setting Expectations
Getting Better all the Time
Chapter 37: Maintaining a Project
What’s a Drupal Project?
Set Up Your Drupal.org Account for Contributing
Creating a Sandbox Project
Status
Project Information
Digging in with Git
Managing SSH
Hack on Your Project
From Sandboxville to Projectopolis
About Branches and Tags on Drupal.org
Preparing a Branch for Your Application
Preparing Your Project for Review
Applying for Access
Receiving Access
Summary
Chapter 38: Contributing to the Community
Why Contribute?
Without Contributions, There Is No Drupal
Taking That First Step
Ways to Contribute
1. Providing Non-Technical Support
2. Sharing Everything
3. Answering Questions in Forums, Groups, Mailing Lists, Meetups, and IRC
4. Writing Documentation for Drupal.org
5. Contributing Patches
6. Contributing Code and Design
7. Curating Issue Queues
8. Reviewing the Contributions of Others
9. Making Drupal.org Better
10. Hosting and Organizing Meetups, Camps, Summits, and More
11. Money
12. Making the Drupal Community Welcoming
Building the Movement
Part VIII: Appendix
Appendix A: Upgrading a Drupal Site from 6 to 7
Assess the Situation
Content Overview
Contributed Modules
Create a Plan
Run the Upgrade (Again and Again)
Preparation
Drush Aliases for All Sites Involved in the Upgrade
A Middle Way
Capturing Additional Upgrade Steps in Update Hooks
Optional: Begin the Custom Upgrade Functions from the Drupal 7 Version of the Site's Glue Code Module
Creating an Upgrade Module
Enabling Modules in Code
Disabling Modules in Code
Automating the Fields Upgrade
Rerunning the Upgrade
Create a Feature
Consider Creating a Base Feature Module
Building a Feature Module
Adding Feature Modules to the Automatic Upgrade
Data Migration
Managing the Process
Understanding the Legacy Data
Specific Sticking Points
Initial Analysis
Iterate
Show
Audit
Time
Launch Day
Summary
Appendix B: Profiling Drupal and Optimizing Performance
User-Perceived Performance
What Makes a Web Site Slow?
Real Performance
Page and Block Level Caching
Profiling Drupal, a Primer
Slow Database Queries
Summary
Appendix C: Page Rendering and Altering
Step 1: The Router Item
Step 2: The Page Callback Is Fired
Step 3: The Delivery Callback
Step 4: drupal_render_page()
Step 5. hook_page_alter()
Step 6. drupal_render()
Appendix D: Visual Design for Drupal
Why Designers Should Work with Drupal
Designing for Drupal: What It Means
Anatomy of a Drupal Page
Design from the Content Out
Making Your Life Easier As a Drupal Designer
Remember—The Purpose of Design Is Communication
Understand Site Architecture and Content Strategy
Choose Fonts Wisely
Clearly Review the Requirements and Outline the Intended Functionality of Special Features
Design for the Entire User Experience
HTML5 in Drupal
How You Can Get Involved
Appendix E: Accessibility
Recent Enhancements
What Are the Standards?
Who Benefits?
It's the Law
Nine Ways to Make Your Site Accessible
Accessible Modules
Theming Your Site
Contrast and Color
Automated Testing
Simulation
Bring in WAI-ARIA
Maintenance is Critical
Schedule Regular Reviews of New and Old Pages
Get Expert Feedback
Appendix F: Windows Development Environment
LAMP to WISP
Visual Studio
WAMP Stack
Drupal Bits
VS.Php
phpMyAdmin and MySQL Connector
Drush
Installing Drush for Windows
Running Drush
Summary
Appendix G: Installing Drupal on Ubuntu
Running Ubuntu on Windows or Mac OS X
Customizing Ubuntu for Drupal Development with Drubuntu
Installing Drupal
Appendix H: Mac OSX Installation
Downloading Drupal Core File
Appendix I: Setting Up a Drupal Environment with the Acquia Dev Desktop
Installation
Taking It Further
Index
← Prev
Back
Next →
← Prev
Back
Next →