function field_collection_field_views_data

cis7 field_collection.views.inc field_collection_field_views_data($field)
cle7 field_collection.views.inc field_collection_field_views_data($field)
elmsmedia7 field_collection.views.inc field_collection_field_views_data($field)
icor7 field_collection.views.inc field_collection_field_views_data($field)
meedjum_blog7 field_collection.views.inc field_collection_field_views_data($field)
mooc7 field_collection.views.inc field_collection_field_views_data($field)

Implements hook_field_views_data().

Adds a relationship to the default field data.

See also

field_views_field_default_views_data()

File

sites/all/modules/ulmus/field_collection/views/field_collection.views.inc, line 15
Views integration for field collection fields.

Code

function field_collection_field_views_data($field) {
  $data = field_views_field_default_views_data($field);

  foreach ($data as $table_name => $table_data) {
    foreach ($table_data as $field_name => $field_data) {
      // Only operate on the "field_api_field_name"_value column.
      if (strrpos($field_name, '_value') === (strlen($field_name) - strlen('_value'))) {
        $data[$table_name][$field_name]['relationship'] = array(
          'handler' => 'field_collection_handler_relationship',
          'base' => 'field_collection_item',
          'base field' => 'item_id',
          'label' => t('field collection item from !field_name', array('!field_name' => $field['field_name'])),
          'field_name' => $field['field_name'],
        );
      }
    }
  }

  foreach ($field['bundles'] as $entity_type => $bundles) {
    $entity_info = entity_get_info($entity_type);
    $pseudo_field_name = $field['field_name'] . '_' . $entity_type;

    list($label, $all_labels) = field_views_field_label($field['field_name']);
    $entity = $entity_info['label'];
    if ($entity == t('Node')) {
      $entity = t('Content');
    }

    $data['field_collection_item'][$pseudo_field_name]['relationship'] = array(
      'title' => t('Entity with the @field (@field_name)', array('@entity' => $entity, '@field' => $label, '@field_name' => $field['field_name'])),
      'help' => t('Relate each @entity using @field.', array('@entity' => $entity, '@field' => $label)),
      'handler' => 'views_handler_relationship_entity_reverse',
      'field_name' => $field['field_name'],
      'field table' => _field_sql_storage_tablename($field),
      'field field' => $field['field_name'] . '_value',
      'base' => $entity_info['base table'],
      'base field' => $entity_info['entity keys']['id'],
      'label' => t('!field_name', array('!field_name' => $field['field_name'])),
    );
  }

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