Support Center

How to name field templates in Drupal 7 in order to override them

Last Updated: Sep 05, 2013 05:49PM EEST
field.tpl.php - The default template implementation to display the value of a field. This file is not used and is here as a starting point for customization only.

The templates that are possible to override include:
  • field.tpl.php
  • field--field-type.tpl.php
  • field--field-name.tpl.php
  • field--content-type.tpl.php
  • field--field-name--content-type.tpl.php
For example, if you want to override the field_image in your product content type, you should create the template field--field_image--product.tpl.php.
Futhermore, if you want to load the node in which field is attached, you should use the $element['#object'] entity.

In case this article leaves any of your questions or concerns unanswered, please feel welcome to email us or post a public question.

​More than (just) Themes

Contact Us
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found