function email_contact_field_formatter_view in Email Contact 7
Implements hook_field_formatter_view().
File
- ./
email_contact.module, line 44 - File name: email_contact.module.
Code
function email_contact_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
$ids = entity_extract_ids($object_type, $object);
if ($ids[0] !== NULL) {
$settings = $display['settings'];
switch ($display['type']) {
case 'email_contact_link':
$link_text = !empty($settings['link_text']) ? $settings['link_text'] : t('Contact person by email');
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = l($link_text, 'email-contact/' . $object_type . '/' . $ids[0] . '/' . $instance['field_name']);
break;
}
break;
case 'email_contact_inline':
foreach ($items as $delta => $item) {
$element[$delta] = email_contact_mail_page($object_type, $ids[0], $instance['field_name'], $settings);
break;
}
break;
}
}
return $element;
}