function hook_field_formatter_view

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 field.api.php hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
cle7 field.api.php hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
elmsmedia7 field.api.php hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
icor7 field.api.php hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
meedjum_blog7 field.api.php hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
mooc7 field.api.php hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)

Build a renderable array for a field value.

Parameters

$entity_type: The type of $entity.

$entity: The entity being displayed.

$field: The field structure.

$instance: The field instance.

$langcode: The language associated with $items.

$items: Array of values for this field.

$display: The display settings to use, as found in the 'display' entry of instance definitions. The array notably contains the following keys and values;

  • type: The name of the formatter to use.
  • settings: The array of formatter settings.

Return value

A renderable array for the $items, as an array of child elements keyed by numeric indexes starting from 0.

Related topics

29 functions implement hook_field_formatter_view()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

date_field_formatter_view in sites/all/modules/ulmus/date/date.field.inc
Implements hook_field_formatter_view().
ds_field_formatter_view in sites/all/modules/ulmus/ds/ds.module
Implements hook_field_formatter_view().
email_field_formatter_view in sites/all/modules/ulmus/email/email.module
Implements hook_field_formatter_view().
entityreference_field_formatter_view in sites/all/modules/ulmus/entityreference/entityreference.module
Implements hook_field_formatter_view().
feeds_node_helper_export_field_formatter_view in sites/all/modules/elmsln_contrib/feeds_node_helper/features/feeds_node_helper_export/feeds_node_helper_export.module
Implements hook_field_formatter_view().

... See full list

File

modules/field/field.api.php, line 1204

Code

function hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];

  switch ($display['type']) {
    case 'sample_field_formatter_simple':
      // Common case: each value is displayed individually in a sub-element
      // keyed by delta. The field.tpl.php template specifies the markup
      // wrapping each value.
      foreach ($items as $delta => $item) {
        $element[$delta] = array('#markup' => $settings['some_setting'] . $item['value']);
      }
      break;

    case 'sample_field_formatter_themeable':
      // More elaborate formatters can defer to a theme function for easier
      // customization.
      foreach ($items as $delta => $item) {
        $element[$delta] = array(
          '#theme' => 'mymodule_theme_sample_field_formatter_themeable',
          '#data' => $item['value'],
          '#some_setting' => $settings['some_setting'],
        );
      }
      break;

    case 'sample_field_formatter_combined':
      // Some formatters might need to display all values within a single piece
      // of markup.
      $rows = array();
      foreach ($items as $delta => $item) {
        $rows[] = array($delta, $item['value']);
      }
      $element[0] = array(
        '#theme' => 'table',
        '#header' => array(t('Delta'), t('Value')),
        '#rows' => $rows,
      );
      break;
  }

  return $element;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.