You are here

function atom_reference_field_views_data in Scald: Media Management made easy 7

Implements hook_field_views_data().

File

modules/fields/atom_reference/atom_reference.module, line 80
Defines a new field type, allowing to directly reference Scald Atoms from a node.

Code

function atom_reference_field_views_data($field) {
  $data = field_views_field_default_views_data($field);
  $current_table = _field_sql_storage_tablename($field);
  $revision_table = _field_sql_storage_revision_tablename($field);
  $column = _field_sql_storage_columnname($field['field_name'], 'sid');

  // Relationship: add a relationship for related atom.
  $data[$current_table][$column]['relationship'] = array(
    'base' => 'scald_atoms',
    'field' => $column,
    'handler' => 'views_handler_relationship',
    'label' => $data[$current_table][$field['field_name']]['title'],
    'field_name' => $field['field_name'],
  );

  // Relationship: add a relationship for revisions.
  $data[$revision_table][$column]['relationship'] = array(
    'base' => 'scald_atoms',
    'field' => $column,
    'handler' => 'views_handler_relationship',
    'label' => t('Atom reference item revision from !field_name', array(
      '!field_name' => $field['field_name'],
    )),
    'field_name' => $field['field_name'],
  );
  return $data;
}