field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)Builds a renderable array for field values.
$entity_type The type of $entity; e.g. 'node' or 'user'.
$entities An array of entities being displayed, keyed by entity id.
$field The field structure for the operation.
$instances Array of instance structures for $field for each entity, keyed by entity id.
$langcode The language associated to $items.
$items Array of field values already loaded for the entities, keyed by entity id.
$display Can be either:
modules/field/field.default.inc, line 167
<?php
function field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$addition = array();
// Prepare incoming display specifications.
if (is_string($display)) {
$view_mode = $display;
$display = $instance['display'][$view_mode];
}
else {
$view_mode = '_custom_display';
}
if ($display['type'] !== 'hidden') {
// We never want to index fields labels.
if ($view_mode == 'search_index') {
$display['label'] = 'hidden';
}
// Calling the formatter function through module_invoke() can have a
// performance impact on pages with many fields and values.
$function = $display['module'] . '_field_formatter_view';
if (function_exists($function)) {
$elements = $function($entity_type, $entity, $field, $instance, $langcode, $items, $display);
if ($elements) {
$info = array(
'#theme' => 'field',
'#weight' => $display['weight'],
'#title' => t($instance['label']),
'#access' => field_access('view', $field, $entity_type, $entity),
'#label_display' => $display['label'],
'#view_mode' => $view_mode,
'#language' => $langcode,
'#field_name' => $field['field_name'],
'#field_type' => $field['type'],
'#field_translatable' => $field['translatable'],
'#object_type' => $entity_type,
'#bundle' => $bundle,
'#object' => $entity,
'#items' => $items,
'#formatter' => $display['type']
);
$addition[$field['field_name']] = array_merge($info, $elements);
}
}
}
return $addition;
}
?>