What about adding a new display style for this field so that instead of displayind a link it actually displays an embedded contact form? Or for even better usability an AJAX form would be even nicer.

Comments

ximo’s picture

Version: 6.x-1.2 » 6.x-1.x-dev

You mean something like this? (Goes into template.php of your theme.)

/**
 * Theme preprocess function for field.tpl.php.
 */
function THEME_NAME_preprocess_content_field(&$variables) {
  $element = $variables['element'];
  $field = content_fields($element['#field_name'], $element['#node']->type);
  $node = $element['#node'];

  if ($field['field_name'] == 'field_FIELD_NAME') {
    $variables['items'][0]['view'] = drupal_get_form('email_mail_page_form', $node, $field['field_name'], $variables['items'][0]['email']);
  }
}

I might look into writing a patch with a display style that does this during the weekend, but can't guarantee I get the time. If I don't, feel free to pick this up someone :)

pauldawg’s picture

Hmmm... well at first glance, that looks right, but I replaced the all-caps areas and it had no effect at all. Not sure if there is something I am missing. I've tried putting this in template.php and in field.tpl.php, with no effect.

But yes, this would need to use its own display style, as there are other views in which I actually show the email address itself. Or alternately, it could just show whenever "email contact form" is the chosen display style.

lorenlang’s picture

ximo: This worked perfectly for me (v6.13) by only changing the THEME_NAME and FIELD_NAME. Thanks much!

pauldawg: What are you seeing? Are you getting anything? Show us a screenshot maybe?

perke’s picture

It does work when using default node.tpl but how do you go about adding this into custom node-type.tpl ?

I added

<?php print $node->field_email[0]['view'] ?>

but got only link to form. what am I missing?

johnv’s picture

Does the following D7-patch help? #1264210: Add actual contact form display formatter