Community & Support

How do i create a email link in a field and have it become a link as well as check its input format?

I have created a new content type called Biography with a new field called email. However the link is not wrapped in a Mailto Achor tag and the email is not validated.

I would like the user to have Drupal validate its format as well as make it a mailto link.

Is this possible?

Comments

You may need to provide more

You may need to provide more info on this as this is currently a little vague, but from what I get so far, just override the content type with a tpl file and format the link that way. So for example:

Create a file called node-biography.tpl.php (or whatever your content type name is specifically)

Inside that file, take away the print $content and add your own code to print the parts of the nodes that you want. I don't know how you created the email field (CCK ?) but if you where using CCK, then you could do something like this:

<?php
print l($node->title, 'mailto:'. $node->field_email[0]['value'])
?>

and that should do the trick, of course with your CCK field exact name. Hope this helps!

Okay I see but is there another way?

So the email is made inside the template not in the content.

Seems to me that there should / would be a content type that would check the input type for a valid email address and automatically wrap in a mailto Anchor.

In your example however It would need to be surrounded by an anchor tag of course.

Its a little confusing to me because I'm no sure how everything works together. For instance I am also using the email obfuscator module too..

Ah I see. It sounds like

Ah I see. It sounds like maybe this is what your looking for instead of doing it the programmatic approach I provided:

http://drupal.org/project/email

Hope that helps!

Yes thats It!

Thank You!

Does it matter?