How to create a content type in a module

You know how to create a module and know that it's easier to add a content type in Drupal and add fields with CCK.

Needed hooks:

    
* hook_node_info()    
* hook_perm()    
* hook_access()    
* hook_form()

Needed if you have additional fields:

  
* hook_insert()
* hook_update()
* hook_delete()
* hook_validate()
* hook_nodeapi()
* hook_view()
* hook_load()

Implementation of hooks:

<?php
/**
*  Implementation of hook_info
*
**/
function siteanalyzer_node_info() {
  return array(
   
'siteanalyzer' => array(
     
'name' => t('site analyse'),
     
'module' => 'siteanalyzer',
     
'description' => "Site analyze node.",
    )
  );

}

/**
*  Implementation of hook_perm
*
**/
function siteanalyzer_perm() {
  return array(
'administer siteanalyzer',
               
'access siteanalyzer',
               
'create siteanalyzer',
               
'edit own siteanalyzer');
}

/**
*  Implementation of hook_access
*
**/
function siteanalyzer_access($op, $node, $account) {

  if (
$op == 'create') {
   
// Only users with permission to do so may create this node type.
   
return user_access('create siteanalyzer', $account);
  }

 
// Users who create a node may edit or delete it later, assuming they have the
  // necessary permissions.
 
if ($op == 'update' || $op == 'delete') {
    if (
user_access('edit own siteanalyzer', $account) && ($account->uid == $node->uid)) {
      return
TRUE;
    }
  }
}


/**
*  Implementation of hook_form
*  Note: The extra fields need the other hooks to be saved, edited and deleted.
**/
function siteanalyzer_form(&$node, $form_state) {

 
$type = node_get_types('type', $node);

 
$form['title'] = array(
   
'#type'=> 'textfield',
   
'#title' => check_plain($type->title_label),
   
'#required' => TRUE,
  );
 
$form['body'] = array(
   
'#type' => 'textarea',
   
'#title' => check_plain($type->body_label),
   
'#rows' => 20,
   
'#required' => TRUE,
  );
 
$form['analyze_path'] = array(
   
'#type' => 'textfield',
   
'#title' => t('Path'),
   
'#default_value' => $node->analyze_path,
   
'#maxlength' => 255,
  );
 
$form['site_pages'] = array(
   
'#type' => 'textfield',
   
'#title' => t('Site pages'),
   
'#default_value' => $node->site_pages,
   
'#maxlength' => 10,
  );
 
$form['external_links'] = array(
   
'#type' => 'textfield',
   
'#title' => t('External linnks'),
   
'#default_value' => $node->external_links,
   
'#maxlength' => 10,
  );


  return
$form;
}
?>

 

 

Source:
Create new content-type for Drupal 6.x
Creating modules - a tutorial: Drupal 6.x
node_example.module 6.x