function content_view_field in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 6.3 content.module \content_view_field()
Render 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 the $FIELD_NAME_rendered variables instead.
By default, the field is displayed using the settings defined for the 'full node' or 'teaser' contexts (depending on the value of the $teaser param). Set $node->build_mode to a different value to use a different context.
Different settings can be specified by adjusting $field['display_settings'].
Parameters
$field: The field definition.
$node: The node containing the field to display. Can be a 'pseudo-node', containing at least 'type', 'nid', 'vid', and the field data.
$teaser:
$page: Similar to hook_nodeapi('view')
Return value
The themed output for the field.
1 call to content_view_field()
- content_content_field_content_type_render in includes/
panels/ content_types/ content_field.inc - Output function for the 'field' content type.
File
- ./
content.module, line 365 - Allows administrators to associate custom fields to content types.
Code
function content_view_field($field, $node, $teaser = FALSE, $page = FALSE) {
$output = '';
if (isset($node->{$field}['field_name'])) {
$items = $node->{$field}['field_name'];
// Use 'full'/'teaser' if not specified otherwise.
$node->build_mode = isset($node->build_mode) ? $node->build_mode : NODE_BUILD_NORMAL;
// One-field equivalent to _content_field_invoke('sanitize').
$field_types = _content_field_types();
$module = $field_types[$field['type']]['module'];
$function = $module . '_field';
if (function_exists($function)) {
$function('sanitize', $node, $field, $items, $teaser, $page);
$node->{$field}['field_name'] = $items;
}
$view = content_field('view', $node, $field, $items, $teaser, $page);
// content_field('view') adds a wrapper to handle variables and 'excluded'
// fields for node templates. We bypass it and render the actual field.
$output = drupal_render($view[$field['field_name']]['field']);
}
return $output;
}