diff --git a/email.info b/email.info index 21fe3bc..ce32f23 100644 --- a/email.info +++ b/email.info @@ -4,3 +4,4 @@ core = 7.x package = Fields files[] = email.migrate.inc +files[] = email.microdata.inc diff --git a/email.microdata.inc b/email.microdata.inc new file mode 100644 index 0000000..90dc6f3 --- /dev/null +++ b/email.microdata.inc @@ -0,0 +1,19 @@ + array('email'), + ); + + return $suggestions; +} diff --git a/email.module b/email.module index 8aaa1fd..88cd04b 100644 --- a/email.module +++ b/email.module @@ -12,6 +12,7 @@ function email_field_info() { 'default_widget' => 'email_textfield', 'default_formatter' => 'email_default', 'property_type' => 'text', + 'microdata' => TRUE, ), ); } @@ -108,6 +109,11 @@ function email_field_formatter_view($object_type, $object, $field, $instance, $l $ids = entity_extract_ids($object_type, $object); foreach ($items as $delta => $item) { $element[$delta] = array('#markup' => l(t('Contact person by email'), 'email/' . $object_type . '/' . $ids[0] . '/' . $instance['field_name'])); + // When Microdata module is enabled, it outputs field values in a + // machine readable form. However, this formatter is selected when + // users don't want the email address to be machine readable. Therefore, + // the microdata mapping should be unset for this formatter. + unset($object->microdata[$field['field_name']]['#attributes']['itemprop']); // Since email is always sent to first item's email, break after any email address found. break; } @@ -129,6 +135,8 @@ function email_field_formatter_view($object_type, $object, $field, $instance, $l $element[$delta] = array('#markup' => $output); } } + // Unset microdata. See comment above in email_contact. + unset($object->microdata[$field['field_name']]['#attributes']['itemprop']); break; } return $element;