You are here

function content_format in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6.3 content.module \content_format()
  2. 6 content.module \content_format()
  3. 6.2 content.module \content_format()

Format a field item for display.

Parameters

$field: Either a field array or the name of the field.

$item: The field item to be formatted (such as $node->field_foo[0]).

$formatter: The name of the formatter to use.

$node: Optionally, the containing node object for context purposes.

Return value

A string containing the contents of the field item sanitized for display. It will have been passed through the necessary check_plain() or check_markup() functions as necessary.

6 calls to content_format()
content_panels_render_field in ./content_panels.inc
content_views_argument_handler in ./content_views.inc
Perform filtering by an argument for field data stored via content.module.
content_views_field_handler_group in ./content_views.inc
content_views_field_handler_ungroup in ./content_views.inc
hook_field in ./field.php
Define the behavior of a field type.

... See full list

File

./content.module, line 1010
Allows administrators to associate custom fields to content types.

Code

function content_format($field, $item, $formatter = 'default', $node = NULL) {
  if (!is_array($field)) {
    $field = content_fields($field);
  }
  $field_types = _content_field_types();
  $formatters = $field_types[$field['type']]['formatters'];
  if (!isset($formatter, $formatters, $formatters[$formatter])) {
    $formatter = 'default';
  }
  return module_invoke($formatters[$formatter]['module'], 'field_formatter', $field, $item, $formatter, $node);
}