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

nvisioncurtis - July 20, 2009 - 22:47

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?

You may need to provide more

nrussell - July 20, 2009 - 23:42

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?

nvisioncurtis - July 21, 2009 - 12:27

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

nrussell - July 21, 2009 - 14:46

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!

nvisioncurtis - July 22, 2009 - 16:58

Thank You!

Do you know if I would use emailobfusticator module or SpanSpam?

nvisioncurtis - July 22, 2009 - 17:04

Does it matter?

 
 

Drupal is a registered trademark of Dries Buytaert.