Book Image

Drupal 7 Module Development

By : Matt Butcher, Larry Garfield, John Wilkins, Matt Farina, Ken Rickard, Greg Dunlap
Book Image

Drupal 7 Module Development

By: Matt Butcher, Larry Garfield, John Wilkins, Matt Farina, Ken Rickard, Greg Dunlap

Overview of this book

<p>Drupal is an award-winning open-source Content Management System. It's a modular system, with an elegant hook-based architecture, and great code. Modules are plugins for Drupal that extend, build or enhance Drupal core functionality.</p> <p>In Drupal 7 Module development book, six professional Drupal developers use a practical, example-based approach to introduce PHP developers to the powerful new Drupal 7 tools, APIs, and strategies for writing custom Drupal code.</p> <p>These tools not only make management and maintenance of websites much easier, but they are also great fun to play around with and amazingly easy to use.<br /><br />If you're eager to learn about these new APIs and start creating modules for Drupal 7, this is your book. Walk through the development of complete Drupal modules with this primer for PHP programmers.</p> <p>From basic modules and themes to sophisticated Drupal extensions, learn how to use Drupal's API and hook system to build powerful custom Drupal websites. With an emphasis on practical programming, this book takes a project-based approach, providing working examples in every chapter<br />Specifically written for Drupal 7, this book will get you coding modules as quickly as possible, and help you add the features that will give your work that professional gloss!<br /><br />This book will walk you through the development of complete Drupal modules and show you how to add various features to meet your requirements.</p> <p>The Drupal content management system, written in the popular PHP language, has skyrocketed in popularity.<br /><br />Developers for this system are in high demand. This book prepares PHP developers for Drupal development, explaining architecture, exploring APIs, and emphasizing practical approaches.</p> <p>In each chapter, readers will learn new aspects of the system while creating fully-functioning modules, themes, and libraries. Learn how to “hook into” any part of the Drupal process, creating custom content types, extending existing capabilities, and integrating with external services and applications.</p>
Table of Contents (22 chapters)
Drupal 7 Module Development
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

The token system


It would be nice if we could include some personalized information in the mail text without having to hardcode it in the module configuration form. For instance, we should be able to include the login of the user being warned, or the name of the site admin. This leads us into our final topic, using Drupal's token system.

What are tokens?

A token is a small piece of text that can be placed into a piece of text via the use of a placeholder. When the text is passed through the function token_replace(), then the tokens are replaced with the appropriate information. Tokens allow users to include data that could change in text blocks, without having to go back and change it everywhere they're referenced.

Tip

In previous versions of Drupal, tokens were implemented using the contributed module named, not surprisingly, Token. This functionality proved to be so popular and widely used that it was included in core for Drupal 7.

A sample token is [site:name]. When text containing this token...