hook_field_display_ENTITY_TYPE_alter
function hook_field_display_ENTITY_TYPE_alter
hook_field_display_ENTITY_TYPE_alter(&$display, $context)
Alters the display settings of a field on a given entity type before it gets displayed.
Modules can implement hook_field_display_ENTITY_TYPE_alter() to alter display settings for fields on a specific entity type, rather than implementing hook_field_display_alter().
This hook is called once per field per displayed entity. If the result of the hook involves reading from the database, it is highly recommended to statically cache the information.
Parameters
$display: The display settings that will be used to display the field values, as found in the 'display' key of $instance definitions.
$context: An associative array containing:
- entity_type: The entity type; e.g., 'node' or 'user'.
- field: The field being rendered.
- instance: The instance being rendered.
- entity: The entity being rendered.
- view_mode: The view mode, e.g. 'full', 'teaser'...
See also
Related topics
File
- modules/field/field.api.php, line 2401
- Hooks provided by the Field module.
Code
function hook_field_display_ENTITY_TYPE_alter(&$display, $context) { // Leave field labels out of the search index. if ($context['view_mode'] == 'search_index') { $display['label'] = 'hidden'; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!field.api.php/function/hook_field_display_ENTITY_TYPE_alter/7.x