node_example.module

Version

1.26 (checked in on 2008/01/19 at 21:13:58 by bdragon)

Description

This is an example outlining how a module can be used to define a new node type.

Our example node type will allow users to specify a "color" and a "quantity" for their nodes; some kind of rudimentary inventory-tracking system, perhaps? To store this extra information, we need an auxiliary database table.

Database definition:

<?php

CREATE TABLE node_example (
vid int(10) unsigned NOT NULL default '0',
nid int(10) unsigned NOT NULL default '0',
color varchar(255) NOT NULL default '',
quantity int(10) unsigned NOT NULL default '0',
PRIMARY KEY (vid, nid),
KEY `node_example_nid` (nid)
)

?>

Functions

Namesort iconDescription
node_example_accessImplementation of hook_access().
node_example_deleteImplementation of hook_delete().
node_example_formImplementation of hook_form().
node_example_insertImplementation of hook_insert().
node_example_loadImplementation of hook_load().
node_example_nodeapiImplementation of hook_nodeapi().
node_example_node_infoImplementation of hook_node_info(). This function replaces hook_node_name() and hook_node_types() from 4.6. Drupal 5 expands this hook significantly.
node_example_permImplementation of hook_perm().
node_example_themeImplementation of hook_theme().
node_example_updateImplementation of hook_update().
node_example_validateImplementation of hook_validate().
node_example_viewImplementation of hook_view().
theme_node_example_order_infoA custom theme function.
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.