Correlating the New Table with Nodes

The install script defined a new table. But how does Drupal know that this table is to be treated as part of a content type? In fact, how is Drupal to know that we are defining a content type at all?

In the first chapter, we discussed nodes. From the developer's point of "

view, each piece of content is backed by a node and (perhaps) some extensions to that node. What extensions are used depends on the content type of that piece of content. The table we just created represents extensions to the node for our biography content type. m

The hook function hook_node_info() is used to register a new content type. Other functions that we will look at shortly (namely, our implementation of hook_load()) will provide Drupal with information on how we have augmented the node with our custom fields.

An implementation of the hook_node_info() hook must return an array of information about the node. This information is basic, and does not include details about the table we have created. Most of the options, in fact, deal with how the basic content authoring form is displayed.

Hence, we will take a quick look at the content authoring form for a Story content type before looking at the hook_node_info() code for our biography module. This will give us the basis for a visual comparison.

The name of this content type is Story. The description of a Story, which appears on the Create content page, reads as follows:

A story, similar in form to a page, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a story entry. By default, a story entry is automatically featured on the site's initial home page, and provides the ability to post comments.

By default, the Create content page is accessible from the main site navigation, or through a URL like this: drupal/?q=node/add (replacing with your domain).

Article Marketing Knockdown

Article Marketing Knockdown

The lifeblood of any online business is in being able to generate highly targeted, consistent traffic to your websites, landing pages and squeeze pages.

Get My Free Ebook

Post a comment