Active
Project:
Email Field
Version:
7.x-1.2
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Nov 2008 at 22:16 UTC
Updated:
16 Dec 2012 at 01:21 UTC
Instead of having the link to the email form for this module read Email contact form, can we change it so that we can put in our own custom text? On my site I want to use the names and job title of the person whose email it is for the link.
Is this possible?
Thanks,
Becky
Comments
Comment #1
malc_b commentedString override module will change the strings, the cck field title and the contact form page title too (SO is case sensitive). I don't think you can change the contact form to say Contact Mr Big as the token wouldn't be available on that page. Might work on the cck field page though.
Comment #2
beckyjohnson commentedThanks for the tip. I think it's ok if the contact form doesn't have the Contact Mr. Big on it, just as long as the link going to it does say his name..
Thanks,
I will play around with this.
Becky
Comment #3
malc_b commentedAdd contact Mr Big is tricky. The work around I have is to code the link separately. If you enable the email form then the rendered page gets a link like /email/4/field_contact where 4 is $node->nid and field_contact is the name you gave the contact email field. So if you set in display fields to exclude the email form then the automatic link disappears. You can then add in your own button or link with php i.e.
where $realname is the person's name, perhaps a field.
The only way to get the name on the contact form I think is to insert the form into another node with cck perhaps. Or you could have a custom tpl file page-email.tpl.php in your theme directory. Or add to theme template.php a rewrite function - function mythemename_preprocess_page(&$vars). That can alter all the page variables. I'm not sure which is the faster as you could just rewrite the variables at the start of page-email.tpl.php then include the standard page.tpl.php
Comment #4
jastraat commentedI solved this by adding the following function to my theme's template.php file
Comment #5
beckyjohnson commentedOh! Great. Will this work for D6?
Becky
Comment #6
jastraat commentedSorry - to clarify, the code above is for Drupal 6. I don't think this exact code will work in Drupal 5 although you might be able to do something similar with the phptemplate variables.
Comment #7
beckyjohnson commentedOk, so I put the function in my template and cleared my cache, and edited an old node that had a contact field on it, made with this module. Then I saved it and tested it .... nothing happened on the contact form.... is there some other setting to change?
Becky
Comment #8
jastraat commentedJust to check - did you replace 'themename' with the name of your theme?
Comment #9
beckyjohnson commentedOh! No . I didn't even notice that. Thank you. I'll fix it.
Becky
Comment #10
beckyjohnson commentedOk! It totally works now. Is there a way to use some other variable so that instead of printing out the node title, you could get it to print out the email address the form would be going to?
Thanks,
Becky
Comment #11
jastraat commentedSure - the $node object should contain all the fields related to that node, including the email address field. To find the field name to call, you could use the devel module to find the values or use print_r() temporarily to print out the contents of the node object.
One word of caution though - if you print out the email address in the title, you're exposing that email address to spam harvesters and negate most of the point of using a contact form.
Comment #12
beckyjohnson commentedThanks, that's good to know. You are right about the spam harvesters. I think what I"ll do is just print out the company name, in my case, that is associated with the email. I wish I could print out the name of the person that email belongs to, but the email module doesn't seem to provide for a name to be associated with an address..
Becky
Comment #13
pam.pkrweb@gmail.com commentedHi
Thanks for this great posting it was great help.
Here is another option for #3 which does not use php. The code can go right in the view in the email fields 'Rewrite the output of this field'. Like this
You have make sure you inlclude the node nid as one of you fields and just check exclude from display. The title has my user name.
Also, has a note if you already of a the themename_preprocess_page function in your template.php you can just add the code into it.
Again, thanks worked great.
Pam
Comment #14
flortjes commentedHi,
Absolutely brilliant.
I like the View rewrite approach. Just for anyone reading this thread. Make sure you add the node id field above (!) the e-mail field. Also, make sure the title field is not a link to anything (the token captures such a link). If it is a link, you could just add another (not linked) title field.
Flor
Comment #15
rkendall commented@jastraat #4 - thanks very much for the handy tip, works a treat! :-)
Comment #16
kaido.toomingas commentedCan I do some like that for this one.. code from email.module
Comment #17
kaido.toomingas commentedCan I do some like that for this one.. code from email.module
Comment #18
kaido.toomingas commentedSome for this topic
Comment #19
tnanek commentedHow about setting it up so that the field's options on the field display configuration screen have an ability to set the text that appears for the link to the contact form.
Just brainstorming here; I may work on a patch if this would be a friendly approach to the maintainers; until something like that is done, the above workarounds are adequate enough.
Also, this specific approach would only apply to the D7 branch, though I'm sure you could add configuration options to the CCK field display configuration screen as well.
Comment #20
brylie commentedI would also like to rewrite the node view of the email field. I think tnanek has a good idea.