function uuidreference_field_formatter_view in UUID reference field 7
Implements hook_field_formatter_view().
File
- ./
uuidreference.module, line 381
Code
function uuidreference_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$result = array();
switch ($display['type']) {
case 'uuidreference_label':
$ref_entity_type = $field['settings']['target_type'];
foreach ($items as $delta => $item) {
$label = entity_label($ref_entity_type, $item['entity']);
// If the link is to be displayed and the entity has a uri, display a link.
if ($display['settings']['link'] && ($uri = entity_uri($ref_entity_type, $item['entity']))) {
$result[$delta] = array(
'#markup' => l($label, $uri['path'], $uri['options']),
);
}
else {
$result[$delta] = array(
'#markup' => check_plain($label),
);
}
}
break;
}
return $result;
}