function field_view_value

×

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.module field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL)
cle7 field.module field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL)
elmsmedia7 field.module field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL)
icor7 field.module field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL)
meedjum_blog7 field.module field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL)
mooc7 field.module field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL)

Returns a renderable array for a single field value.

Parameters

$entity_type: The type of $entity; e.g., 'node' or 'user'.

$entity: The entity containing the field to display. Must at least contain the id key and the field data to display.

$field_name: The name of the field to display.

$item: The field value to display, as found in $entity->field_name[$langcode][$delta].

$display: Can be either the name of a view mode, or an array of display settings. See field_view_field() for more information.

$langcode: (Optional) The language of the value in $item. If not provided, the current language will be assumed.

Return value

A renderable array for the field value.

Related topics

File

modules/field/field.module, line 792
Attach custom data fields to Drupal entities.

Code

function field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL) {
  $output = array();

  if ($field = field_info_field($field_name)) {
    // Determine the langcode that will be used by language fallback.
    $langcode = field_language($entity_type, $entity, $field_name, $langcode);

    // Push the item as the single value for the field, and defer to
    // field_view_field() to build the render array for the whole field.
    $clone = clone $entity;
    $clone->{$field_name}[$langcode] = array($item);
    $elements = field_view_field($entity_type, $clone, $field_name, $display, $langcode);

    // Extract the part of the render array we need.
    $output = isset($elements[0]) ? $elements[0] : array();
    if (isset($elements['#access'])) {
      $output['#access'] = $elements['#access'];
    }
  }

  return $output;
}
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.