function ref_field_field_formatter_view in (Entity)Reference Field Synchronization 7
Implements hook_field_formatter_view().
File
- ./
ref_field.module, line 384
Code
function ref_field_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'ref_field_id':
foreach ($items as $delta => $item) {
$e = $item['entity'];
$e_type = $field['settings']['entity'];
$output = $item['eid'];
// Link to content if setting is selecetd
if ($display['settings']['linked']) {
$uri = entity_uri($e_type, $e);
$output = l($output, $uri['path'], $uri['options']);
}
$element[$delta] = array(
'#markup' => $output,
);
}
break;
case 'ref_field_title':
foreach ($items as $delta => $item) {
$e = $item['entity'];
$e_type = $field['settings']['entity'];
$output = entity_label($e_type, $e);
// Link to content if setting is selecetd
if ($display['settings']['linked']) {
$uri = entity_uri($e_type, $e);
$output = l($output, $uri['path'], $uri['options']);
}
$element[$delta] = array(
'#markup' => $output,
);
}
break;
}
return $element;
}