All themes usually come with a default node.tpl.php template. Drupal core lets you use the following variant (suggestion):
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.
CCK makes the following variables available in your theme's node templates:
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().
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.
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).
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:
The following additional variables are available in templates for referenced nodes: