Correlating the New Table with Nodes

How To Make Money Writing Web Articles

Automatic Content Generation with Article Spinner

Get Instant Access

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).

Was this article helpful?

0 0
Make Money Writing

Make Money Writing

This Report Will Show You How To Make Money By Providing Writing Services To Other Internet Marketers. Learn how to make money by writing the right way. Grab your copy of this report now and learn. Why writing is a great way to earn money. How to compete with cheap writers, even if you charge a lot more money.

Get My Free Ebook

Post a comment