logo

Palette - Make it Colorful🎨

Palette - Visual Page Builder, no design degree required.

Live Demo Download Palette

Scroll

Drupal theming lesson 5 Field theming. Field.tpl.php template

17/04/2025, by Ivan

In this lesson, we continue theming Drupal, and this time we will theme fields. After this lesson, we will move on to theming Views output.

To theme a field, you need to copy the file modules/field/theme/field.tpl.php into your theme's templates folder and rename it according to one of the following patterns:

  • field--FIELD_TYPE.tpl.php — this template will apply to all fields of type FIELD_TYPE. For example, to theme all image fields, create a template named field--image.php.

  • field--FIELD_NAME.tpl.php — this template will apply to the field named FIELD_NAME. For example, to theme the field named field_images, create a template named field--field_images.tpl.php.

  • field--BUNDLE.tpl.php — this template will apply to all fields added to an entity of type BUNDLE. For example, to theme all fields in a content type called page, create a template named field--page.tpl.php.

  • field--FIELD_NAME--BUNDLE.tpl.php — this template will apply only to the field FIELD_NAME that belongs to an entity of type BUNDLE. For example, to theme the field_images field in a content type called page, create a template named field--field_images--page.tpl.php.

After copying and renaming the template, clear the cache and edit the new file. Descriptions of all available variables are included in the template’s comments.