### Template files

All themes usually come with a default node.tpl.php template. Drupal core lets you use the following variant (suggestion):

node-<CONTENT_TYPE_NAME>.tpl.php
  ex: node-story.tpl.php - If present, will be used to theme a 'story' node.

Important: whenever you add new template files in your theme, you need to rebuild the theme registry, or the theme engine won't see them.
You can do that by :
- visiting the Administer modules page
- or using Devel module's 'clear cache' link.

### Template variables

CCK makes the following variables available in your theme's node templates:

$<FIELD_NAME>_rendered
  Contains the rendered html for the field, including the label and all the field's values, with the settings defined on the Display fields tab.
$<GROUP_NAME>_rendered
  Contains the rendered html for the fieldgroup (if any), including the label and all the group's fields, with the settings defined on the Display fields tab.
  This variable therefore includes the html contained in all the $<FIELD_NAME>_rendered variables for the group's fields.
$FIELD_NAME
  Contains the raw values of the fields, in the usual array-format used internally by CCK. What you find in there depends on the field type.
  Each value also contains a 'view' element, that holds the ready-to-display value as rendered by the formatter. For instance:

      array(
        0 => array(
          'nid' => 5,
          'view' => '<a href="node/5">Title of node 5</a>',
        ),
      );

  Raw data are not sanitized for output, it is therefore not advised to use them directly. Use the 'view' value, or run the values through content_format().

### Excluding fields from the $content variable

By default, the $content variable used in node templates contains the rendered html for the whole node : CCK fields and fieldgroups, but also body, file attachments, fivestar widgets, ...

If for some fields you want to use the more fine-grained variables described above, you might want to use the Exclude checkboxes on the Display fields screen, so that the output of those fields is excluded from the $content variable.

You can then customize the display and layout of some CCK fields or groups using the $<FIELD_NAME>_rendered / $<GROUP_NAME>_rendered variables, and trust $content to display 'the rest' without getting duplicate information.

##### Advanced trick

The Exclude checkboxes affect all active themes. On sites with multiple themes, however, the list of fields to exclude from $content might need to be different across the themes, depending on how their respective node templates are structured.

A theme can bypass those settings by overriding the theme_content_exclude() function to specify the list of fields to exclude for this theme (see the PHPDoc of the function for more information).

### Special case : nodes in nodereference fields

In addition to the above, the following suggestions will be looked for in priority for nodes that are displayed as values of a nodereference field using the 'teaser' or 'full node' formatters:

node-nodereference-<REFERRING_FIELD_NAME>-<TYPE_NAME>.tpl.php
  ex: node-nodereference-field_noderef-story.tpl.php - If present, will be used to theme a 'story' node when refererenced in the 'field_noderef' field.
node-nodereference-<TYPE_NAME>.tpl.php
  ex: node-nodereference-story.tpl.php - If present, will be used to theme a 'story' node when refererenced in any nodereference field.
node-nodereference-<REFERRING_FIELD_NAME>.tpl.php
  ex: node-nodereference-field_noderef.tpl.php - If present, will be used to a node refererenced in the 'field_noderef' field.
node-nodereference.tpl.php
  If present, will be used to theme nodes referenced in nodereference fields.

The following additional variables are available in templates for referenced nodes:

$referring_field
  The nodereference field that references the current node.
$referring_node
  The node referencing the current node.