Version 1.7 (checked in on 2010/10/15 at 14:52:26 by rfay)
This is an example outlining how a module can be used to define a new node type. In Drupal 7 we move most of what was once needed in this file to the node_example.install file so that it can be managed efficiently.
Our example node type will allow users to specify multiple "colors", a "quantity" and an "image" for their nodes; some kind of rudimentary inventory-tracking system, perhaps?
In previous versions of Drupal, "teaser" and "page" were node view modes. In Drupal 7 we can define custom view modes to let the node know how it should return it's data. This module declares a custom view mode called "example_node_list".
We no longer need an extra database table to store this content type's information.
Most node types that provide fields do not require any custom code for the fields, as the fields system provides storage and access.
Remember that most node types do not require any custom code, as one simply creates them using the fields UI.
| Name | Description |
|---|---|
| node_example_entity_info_alter | Implements hook_entity_info_alter(). |
| node_example_field_formatter_info | Implements hook_field_formatter_info(). |
| node_example_field_formatter_view | Implements hook_field_formatter_view(). |
| node_example_help | Implements hook_help(). |
| node_example_menu | Implements hook_menu(). |
| node_example_page | Custom callback that builds our content and returns it to the browser. |
| node_example_theme | Implements hook_theme(). |
| theme_example_node_color | A custom theme function. |