18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table of Contents<br />

A shortcut for system settings 138<br />

A shortcut for confirmation forms 139<br />

Sending mail with drupal_mail() and hook_mail() 141<br />

Calling drupal_mail() 142<br />

Implementing hook_mail() 144<br />

The token system 146<br />

What are tokens? 146<br />

Implementing tokens in your text 147<br />

Summary 149<br />

Chapter 6: Working with Content 151<br />

Why create your own entities 151<br />

The goal 152<br />

Bundles 152<br />

The Schema API 152<br />

Declaring our entity 156<br />

The entity declaration 156<br />

The entity controller 161<br />

Entity management 163<br />

Managing artwork types 163<br />

Adding artworks 165<br />

Adding new artwork 167<br />

Validation callback 170<br />

Submit callback 171<br />

Saving your artwork 172<br />

Handling revisions 175<br />

Viewing artworks 176<br />

Editing an artwork 177<br />

Deleting an artwork 178<br />

Summary 182<br />

Chapter 7: Creating New Fields 183<br />

Our goal: a "dimensions" field 183<br />

How Field API works 184<br />

Creating our new field type 185<br />

Declaring the field 185<br />

Defining the field structure 186<br />

Defining empty 188<br />

Field settings 188<br />

Field validation 189<br />

Exposing fields to the Form API with widgets 191<br />

Declaring a widget 191<br />

[ iv ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!