02. Name the new node type
With our basic outline of a module handy, we want to start defining the node. First, we need to inform Drupal that we have a new node type, by specifying its name and how Drupal should access the module's functions.
The array returned by the node_info hook specifies the human readable module name, "to-do" in our case, and the prefix of our module's functions, "todo" for this module. This means, our function names will be accessed via todo_insert and todo_validate. If we used "pineapple" as our "base" value, we would need to define our functions with a pineapple_ prefix: pineapple_insert, pineapple_validate, etc.
Read more about the node_info hook.
<?php
/**
* Implementation of hook_node_info().
* Define the node type
*/
function todo_node_info() {
return array('todo' => array('name' => t('to-do'), 'base' => 'todo'));
}
?>At this point, if you install the module, enable it, grant the module's permissions to a user, and access the create content link, you'll see the link to create a to-do node in the node/add page (your page may differ, depending on your installation and configuration):
Selecting this link will show you the surrounding information associated with a new node, based on what modules you have installed, activated and permissions for. However, there is no way to create the content for this node.

warning: array_merge_recursive()
I had a problem when trying to to this, I got the following error
when i accesed the page to create a new "to do" node. I think the problem may be becuase i am running drupal 5 and this tutorial is for 4.7.
After looking around in the forums I managed to fix this, I think, by replacing this line of code
return array('todo' => array('name' => t('to-do'), 'base' => 'todo'));with this
return array('todo' => array('name' => t('to-do'), 'base' => 'todo', 'module' => 'todo'));hope this helps
Need the form for v.5 preview
You will get the error mentioned above if you try to preview at this step with Drupal 5. Wait until step 3 to preview...
also get this if...
if the name of the files (e.g. node_example.module) does not match the name in the .info file and the name of the directory it is in. (drupal 5)
It's because the tutorial is
It's because the tutorial is for drupal 4.7.
For drupal 5.1, you have to replace the function "todo_node_info" by something like this :
function todo_node_info() {
return array(
'todo' => array(
'name' => t('To do'),
'module' => 'todo',
'description' => t("You can add a todo list"),
)
);
}
Update 5.x
'base' attribute is named 'module' in 5.x API:
<?php/**
* Implementation of hook_node_info().
* Define the node type
*/
function todo_node_info() {
return array('todo' => array('name' => t('to-do'), 'module' => 'todo'));
}
?>
More info: http://api.drupal.org/api/5/function/hook_node_info