mzambranaa
10/19/2017 - 8:01 AM

Override field.tpl.php

Override field.tpl.php

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

Copy content field.tpl.php module core

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.

For example, if you want to take the language of the node in which field is attached inside a field template, you could use the following code:

<?php $node=$element['#object']; $lang = $node->language; ?>
http://robmalon.com/drupal-7-0-preprocess-page-templates-theme_hook_suggestions/