On this page
function field_get_display
field_get_display($instance, $view_mode, $entity)
Returns the display settings to use for an instance in a given view mode.
Parameters
$instance: The field instance being displayed.
$view_mode: The view mode.
$entity: The entity being displayed.
Return value
The display settings to be used when displaying the field values.
Related topics
File
- modules/field/field.module, line 655
- Attach custom data fields to Drupal entities.
Code
function field_get_display($instance, $view_mode, $entity) {
// Check whether the view mode uses custom display settings or the 'default'
// mode.
$view_mode_settings = field_view_mode_settings($instance['entity_type'], $instance['bundle']);
$actual_mode = (!empty($view_mode_settings[$view_mode]['custom_settings']) ? $view_mode : 'default');
$display = $instance['display'][$actual_mode];
// Let modules alter the display settings.
$context = array(
'entity_type' => $instance['entity_type'],
'field' => field_info_field($instance['field_name']),
'instance' => $instance,
'entity' => $entity,
'view_mode' => $view_mode,
);
drupal_alter(array('field_display', 'field_display_' . $instance['entity_type']), $display, $context);
return $display;
}
© 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.module/function/field_get_display/7.x