Book Image

Learning Drupal 6 Module Development

Book Image

Learning Drupal 6 Module Development

Overview of this book

Table of Contents (14 chapters)
Learning Drupal 6 Module Development
Credits
About the Author
About the Reviewers
Preface

The Module Installation Script


Our new module is going to create a new content type. This new node type will need some additional data fields that the default node implementation does not provide.

Where will these fields be stored?

Answer: In a custom database table.

Thus, when our biography module is first enabled (in Administer | Site building | Modules), we need to make sure that a new table is created. Likewise, when this module is uninstalled (from the Uninstall tab of Administer | Site building | Modules), we need to make sure that the database table is removed.

To accomplish this, we will create a new file, biography.install. When Drupal first enables a module, it looks in the module's directory for a file named<modulename>.install. If it finds this file, it will load it and then check to see if the installation hook, hook_install(), is implemented. If it is, Drupal will execute it.

To create a new table, then, we simply have to implement hook_install() with code for creating a...