PacktLib: Drupal 7 Module Development

Drupal 7 Module Development

Credits

Foreword

About the Authors

About the Reviewers

www.PacktPub.com

Preface

Developing for Drupal 7

Introducing Drupal (for developers)

Drupal architecture

Drupal's major subsystems

Tools for developing Drupal code

Summary

Creating Your First Module

Our goal: a module with a block

Creating a new module

Working with the Block API

Writing automated tests

Summary

Drupal's Theme Layer

Business logic versus presentation logic

Data granularity

Theme engines

Two ways to theme

Render elements

The power of theme()

Theme registry

What else?

Summary

Theming a Module

Reusing a default theme implementation

Steps to build a default theme implementation

Summary

Building an Admin Interface

The User Warn module

Starting our module

The Drupal menu system

Form API

Sending mail with drupal_mail() and hook_mail()

The token system

Summary

Working with Content

Why create your own entities

The goal

Bundles

The Schema API

Declaring our entity

Entity management

Summary

Creating New Fields

Our goal: a "dimensions" field

How Field API works

Creating our new field type

Exposing fields to the Form API with widgets

Using formatters to display our field

Managing non-Field fields

Finding entities and fields

Summary

Drupal Permissions and Security

Using user_access() to assert permissions

Checking the proper user account

Using hook_permission()

Declaring your own access functions

Responding when access is denied

Enabling permissions programmatically

Defining roles programmatically

Securing forms in Drupal

Handling AJAX callbacks securely

Summary

Node Access

Node Access compared to user_access() and other permission checks

Using hook_node_access()

When to write a node access module

Creating the role access module

Modifying the behavior of other modules

Testing and debugging your module

Summary

JavaScript in Drupal

JavaScript inside Drupal

Adding JavaScript

Altering JavaScript

Drupal specific JavaScript

AJAX helpers

Summary

Working with Files and Images

The Twitpic and watermark modules

Files in Drupal

File API

Stream wrappers

Images in Drupal

Summary

Installation Profiles

Introducing installation profiles

Drupal distributions

Creating profiles

Running the installer from the command line

Summary

Database Access

Database Access

Database Access

Database Access

Database Access

Database Access

Database Access

Database Access

Database Access

Database Access

Security

Security

Security

Security

Security

Security

Security