Skip to content

Instantly share code, notes, and snippets.

@rfay
Created April 14, 2011 00:44
Show Gist options
  • Save rfay/918723 to your computer and use it in GitHub Desktop.
Save rfay/918723 to your computer and use it in GitHub Desktop.
function asin_field_views_data($field) {
$data = field_views_field_default_views_data($field);
// Skip items that are already in the views data.
$field_skips = array_keys($data);
array_unshift($field_skips, 'table', 'entity_id', 'revision_id');
foreach ($data as $table_name => $table_data) {
foreach ($table_data as $field_name => $field_data) {
if (!in_array($field_name, $field_skips)) {
$data[$table_name][$field_name]['relationship'] = array(
'handler' => 'views_handler_relationship',
'base' => 'amazon_item',
'base_field' => 'asin',
'label' => t('ASIN from !field_name', array('!field_name' => $field['field_name'])),
);
debug($data[$table_name][$field_name]['relationship'], "\$data[$table_name][$field_name]['relationship']");
}
}
}
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment