Field-level theming determines how the values of a given field are
displayed. The resulting output ends up in the
$content
and
$<FIELD_NAME>_rendered
variables in the node
templates.
Template files
In order to customize field themeing:
-
Copy the
content-field.tpl.php
template file into
your theme's root folder (please keep the contents of the
cck/theme
folder untouched. For the same reason,
need to copy the file instead of just moving it).
-
Edit that copy to your liking. See the comments in
cck/theme/content/content-field.tpl.php
for a list
of all variables available in this template.
Template suggestions
In addition, the theme layer will also look for field-specific variants
(suggestions), in the following order of precedence:
-
content-field-<FIELD_NAME>-<CONTENT_TYPE_NAME>.tpl.php
-
ex:
content-field-field_myfield-story.tpl.php
-
If present, will be used to theme the 'field_myfield' field when displaying
a 'story' node.
-
content-field-<CONTENT_TYPE_NAME>.tpl.php
-
ex:
content-field-story.tpl.php
- If present,
will be used to theme all fields of 'story' nodes.
-
content-field-<FIELD_NAME>.tpl.php
-
ex:
content-field-field_myfield.tpl.php
-
If present, will be used to theme all 'field_myfield' field in all the
content types it appears in.
-
content-field.tpl.php
-
If none of the above is present, the base template will be used.
Important:
-
Suggestions work only if the theme also has the base template file.
If your theme has
content-field-*.tpl.php
files,
it must also have a
content-field.tpl.php
file.
-
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.
See the
Working with template suggestions
section of the
Theme guide for Drupal 6
for more informations about templates and template suggestions.