field_view_field
- Versions
- 7
field_view_field($obj_type, $object, $field, $instance, $build_mode = 'full')
Return a single field, fully themed with label and multiple values.
To be used by third-party code (Views, Panels...) that needs to output an isolated field. Do *not* use inside node templates, use render($content[FIELD_NAME]) instead.
The field will be displayed using the display options (label display, formatter settings...) specified in the $instance structure for the given build mode: $instance['display'][$build_mode].
Parameters
$object The object containing the field to display. Must at least contain the id key, revision key (if applicable), bundle key, and the field data.
$field The field structure.
$instance The instance structure for $field on $object's bundle.
$build_mode Build mode, e.g. 'full', 'teaser'...
Return value
The themed output for the field.
Related topics
Code
modules/field/field.module, line 589
<?php
function field_view_field($obj_type, $object, $field, $instance, $build_mode = 'full') {
$output = '';
if (isset($object->$field['field_name'])) {
$items = $object->$field['field_name'];
// One-field equivalent to _field_invoke('sanitize').
$function = $field['module'] . '_field_sanitize';
if (function_exists($function)) {
$function($obj_type, $object, $field, $instance, $items);
$object->$field['field_name'] = $items;
}
$view = field_default_view($obj_type, $object, $field, $instance, $items, $build_mode);
// TODO : what about hook_field_attach_view ?
$output = $view[$field['field_name']];
}
return $output;
}
?>Login or register to post comments 