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

A Simple Content Type, Defined in Code


In Chapter 4, we created our first custom content type. There, we created the new type through Drupal's administration interface.

In Chapter 7, we created a much more advanced content type. This content type included additional content stored in additional tables.

Here, we will create a simple content type like the one in Chapter 4, but we will do it programmatically. Since we are adding no fields beyond the standard node content, we can create our content type with only two functions (and no database manipulation).

We have covered the techniques for creating content types already, so we will proceed rapidly.

Our new content type will be the news brief content type. This content type will be used to provide some editorial content at the beginning of a new site news email message. Adding such a simple content type in code requires implementing two hooks, both of which we saw in the last chapter:

  • hook_node_info(): Set the defaults for the content type...