Adding content when creating a node I'm currently building a system to create rapports for a set of possible units. So far I have built a set of content types in CCK that acts like templates where the templates fields are used to add structures that the users creating the rapport will fill out.

I have, in my template, a list of "key value names" that will then be added to the rapport and the user can fill them out.

The Template:
a, b, c

The rapport:
* a = x
* b = y
* c = z


where x,y,z is entered by the user generating the rapport.

I found this here on drupal.stackexchange.com and I guess it's on the right track. But I don't understand what I would fill in 'hooks' with and how to limit the action to only trigger on(/before) node creation. There is also a number of sub-nodes that needs to be created based on the templates, but that part I haven't research yet, if it is connected please include information about it in your answer if possible.
Per the question you linked to, the Rules module will do this very well and can be used to call your custom actions when criteria are met during pre-save, validation, or other stages you might need.

It's worth pointing out that, since you want custom nodes created, you're likely to already need to be writing custom code. In this case a better approach might be to write an implementation of hook_nodeapi() (Drupal 6) or hook_node_{operation}() (Drupal 7) that means you can fire your own custom code at specific points during node creation.

Take a look at this question about how to make nodes programatically, and also this article with more detail about the process in Drupal 7 (only in Google cache). Extract of the article:


  1 Initialize a node object

 $node = new stdClass(); // We create a new node object $node-&gt;type =
 "page"; // Or any other content type you want $node-&gt;title = "Your
 title goes jere"; $node-&gt;language = LANGUAGE_NONE; // Or any language
 code if Locale module is enabled. More on this below * $node-&gt;path =
 array('alias' =&gt; 'your node path'); // Setting a node path
 node_object_prepare($node); // Set some default values. $node-&gt;uid =
 1; // Or any id you wish

  
  *We set LANGUAGE_NONE for $node->language, if you don’t have the locale module enabled, the node will not be assigned any particular
  language. So that's why we put here the constant LANGUAGE_NONE. In
  Drupal, nodes and fields can exist in more that one language, so if
  your site is multilingual you should specify the language code for
  your field. You can configure languages and get language codes by
  going this path in Drupal administration: Configuration -> Regional
  and language -> Languages.
  
  2 Add a body field

// Let's add standard body field
$node-&gt;body[$node-&gt;language][0]['value'] = 'This is a body text';
$node-&gt;body[$node-&gt;language][0]['summary'] = 'Here goes a summary';
$node-&gt;body[$node-&gt;language][0]['format'] = 'filtered_html'; // If
field has a format, you need to define it. Here we define a default
filtered_html format for a body field

  
  3 Add custom fields

// Let's add some CCK/Fields API field. This is pretty similar to the
body example  $node-&gt;field_custom_name[$node-&gt;language][0]['value'] =
'This is a custom field value'; // If your custom field has a format,
don't forget to define it here
$node-&gt;field_custom_name[$node-&gt;language][0]['format'] = 'This is a
custom field value'; // And etc. you can add as much fields here as
your content type has. The sky is the limit... and the server specs,
of course ;)

  
  4 Add file / image fields

// Some file on our system $file_path =
drupal_realpath('somefile.png'); // Create a File object $file =
(object) array(   'uid' =&gt; 1,   'uri' =&gt; $file_path,   'filemime' =&gt;
file_get_mimetype($file_path),   'status' =&gt; 1, );  $file =
file_copy($file, 'public://'); // Save the file to the root of the
files directory. You can specify a subdirectory, for example,
'public://images'  $node-&gt;field_image[LANGUAGE_NONE][0] =
(array)$file; //associate the file object with the image field:

  
  5 Add a term to a node

$node-&gt;field_tags[$node-&gt;language][]['tid'] = 1;

  
  field_tags here is the name of a term reference field attached to your
  content type, 1 is a term id you wish to assign to a node. Simple!
  
  6 Save a node

$node = node_submit($node); // Prepare node for a submit
node_save($node); // After this call we'll get a nid