Search and Find
Service
Contents at a Glance
5
Contents
7
Foreword
25
About the Author
26
About the Technical Reviewer
27
Acknowledgments
28
Introduction
29
How Drupal Works
30
What Is Drupal?
30
Technology Stack
30
Core
31
Administrative Interface
32
Modules
32
Hooks
33
Themes
34
Nodes
34
Blocks
35
File Layout
35
Serving a Request
37
Summary
40
Writing a Module
41
Creating the Files
41
Implementing a Hook
43
Adding Module- Specific Settings
44
Adding the Data Entry Form
47
Defining Your Own Administration Section
55
Presenting a Settings Form to the User
57
Validating User- Submitted Settings
59
Storing Settings
60
Further Steps
62
Summary
62
Hooks, Actions, and Triggers
63
Understanding Events and Triggers
63
Understanding Actions
65
Using the Context in Actions
75
Examining the Context
79
How Actions Are Stored
80
Calling an Action Directly with actions_ do()
81
Defining Your Own Triggers with hook_ hook_ info()
82
Adding Triggers to Existing Hooks
84
Summary
86
The Menu System
87
Callback Mapping
87
Menu Nesting
97
Access Control
98
Title Localization and Customization
99
Wildcards in Menu Items
103
Altering Menu Items from Other Modules
108
Altering Menu Links from Other Modules
110
Kinds of Menu Items
110
Common Tasks
111
Using menu. module
115
Common Mistakes
115
Summary
116
Working with Databases
117
Defining Database Parameters
117
Understanding the Database Abstraction Layer
117
Connecting to the Database
119
Performing Simple Queries
120
Retrieving Query Results
122
The Schema API
123
Inserts and Updates with drupal_ write_ record()
134
Exposing Queries to Other Modules with hook_ db_ rewrite_ sql()
136
Connecting to Multiple Databases Within Drupal
139
Using a Temporary Table
140
Writing Your Own Database Driver
140
Summary
141
Working with Users
143
The $ user Object
143
Introduction to hook_ user()
146
The User Registration Process
149
The Login Process
152
External Login
157
Summary
164
Working with Nodes
165
So What Exactly Is a Node?
165
Not Everything Is a Node
168
Creating a Node Module
168
How Nodes Are Stored
185
Creating a Node Type with CCK
186
Restricting Access to Nodes
187
Summary
191
The Theme System
192
Theme System Components
192
Installing a Theme
195
Building a PHPTemplate Theme
196
Understanding Template Files
203
Advanced Drupal Theming
221
Summary
228
Working with Blocks
229
What Is a Block?
229
Block Configuration Options
230
Block Placement
232
Defining a Block
232
Building a Block
236
Enabling a Block When a Module Is Installed
244
Block Visibility Examples
244
Summary
245
The Form API
246
Understanding Form Processing
246
Creating Basic Forms
254
Form API Properties
277
Summary
298
Manipulating User Input: The Filter System
299
Filters
299
Filters and Input Formats
300
Creating a Custom Filter
306
Protecting Against Malicious Data
312
Summary
313
Searching and Indexing Content
314
Building a Custom Search Page
314
Using the Search HTML Indexer
322
Summary
331
Working with Files
332
How Drupal Serves Files
332
PHP Settings
334
Media Handling
335
File API
336
Summary
349
Working with Taxonomy
350
What Is Taxonomy?
350
Kinds of Taxonomy
354
Viewing Content by Term
356
Storing Taxonomies
358
Module- Based Vocabularies
360
Common Tasks
363
Taxonomy Functions
365
Additional Resources
371
Summary
371
Caching
372
Knowing When to Cache
372
How Caching Works
373
How Caching Is Used Within Drupal Core
374
Summary
387
Sessions
388
What Are Sessions?
388
Usage
389
Session- Related Settings
390
Storage
392
Session Life Cycle
393
Session Conversations
395
Common Tasks
396
Summary
398
Using jQuery
399
What Is jQuery?
399
The Old Way
400
How jQuery Works
401
jQuery Within Drupal
403
Building a jQuery Voting Widget
415
Next Steps
427
Summary
427
Localization and Translation
428
Enabling the Locale Module
428
User Interface Translation
428
Starting a New Translation
441
Installing a Language Translation
445
Right- to- Left Language Support
447
Language Negotiation
448
Content Translation
453
Localization- and Translation- Related Files
458
Additional Resources
458
Summary
459
XML-RPC
460
What Is XML- RPC?
460
Prerequisites for XML- RPC
460
XML- RPC Clients
461
A Simple XML- RPC Server
466
Built- In XML- RPC Methods
470
Summary
472
Writing Secure Code
473
Handling User Input
473
Handling URLs Securely
480
Making Queries Secure with db_ query()
481
Keeping Private Data Private with db_ rewrite_ sql()
485
Dynamic Queries
486
Permissions and Page Callbacks
487
Cross- Site Request Forgeries ( CSRF)
488
File Security
488
Encoding Mail Headers
491
Protecting cron. php
492
SSL Support
492
Stand- Alone PHP
493
AJAX Security
494
Form API Security
494
Protecting the Superuser Account
495
Using eval()
496
Summary
496
Development Best Practices
497
Coding Standards
497
PHP Comments
503
Checking Your Coding Style Programmatically
507
Finding Your Way Around Code with egrep
508
Taking Advantage of Version Control
510
Creating and Applying Patches
520
Maintaining a Module
521
Mixing SVN with CVS for Project Management
538
Testing and Developing Code
539
The Module Builder Module
542
Application Profiling and Debugging
542
Summary
544
Optimizing Drupal
546
Finding the Bottleneck
546
Drupal- Specific Optimizations
555
Architectures
561
Summary
564
Installation Profiles
565
Where Profiles Are Stored
565
How Installation Profiles Work
566
Summary
589
Database Table Reference
590
access ( user module)
590
accesslog ( statistics module)
590
actions ( trigger module)
591
actions_ aid ( trigger module)
591
aggregator_ category ( aggregator module)
592
aggregator_ category_ feed ( aggregator module)
592
aggregator_ category_ item ( aggregator module)
592
aggregator_ feed ( aggregator module)
592
aggregator_ item ( aggregator module)
593
authmap ( user module)
593
batch ( batch. inc)
594
blocks ( block module)
594
blocks_ roles ( block module)
595
book ( book module)
595
boxes ( block module)
596
cache
596
cache_ block ( block module)
596
cache_ filter ( filter module)
597
cache_ form
597
cache_ menu
598
cache_ page
598
cache_ update
599
comments ( comment module)
599
contact ( contact module)
600
files ( upload module)
600
filter_ formats ( filter module)
601
filters ( filter module)
601
flood ( contact module)
601
forum ( forum module)
602
history ( node module)
602
languages ( locale module)
602
locales_ source ( locale module)
603
locales_ target ( locale module)
603
menu_ custom ( menu module)
603
menu_ links ( menu module)
604
menu_ router
605
node ( node module)
606
node_ access ( node module)
607
node_ comment_ statistics ( comment module)
608
node_ counter ( statistics module)
608
node_ revisions ( node module)
608
node_ type ( node module)
609
openid_ association ( openid module)
610
permission ( user module)
610
poll ( poll module)
611
poll_ choices ( poll module)
611
poll_ votes ( poll module)
611
profile_ fields ( profile module)
612
profile_ values ( profile module)
612
role ( user module)
613
search_ dataset ( search module)
613
search_ index ( search module)
613
search_ node_ links ( search module)
614
search_ total ( search module)
614
sessions
614
system
615
term_ data ( taxonomy module)
616
term_ hierarchy ( taxonomy module)
616
term_ node ( taxonomy module)
616
term_ relation ( taxonomy module)
616
term_ synonym ( taxonomy module)
617
trigger_ assignments ( trigger module)
617
upload ( upload module)
617
url_ alias ( path module)
618
users ( user module)
618
users_ roles ( users)
619
variable
619
vocabulary ( taxonomy module)
620
vocabulary_ node_ types ( taxonomy module)
620
watchdog ( dblog module)
621
Resources
622
Code
622
Handbooks
623
Forums
623
Mailing Lists
623
User Groups and Interest Groups
625
Internet Relay Chat
625
Videocasts
626
Weblogs
626
Conferences
626
Contribute
627
Index
628
All prices incl. VAT