Please post what you've gotten to work in the way of Email Templating for "Send to a Friend"
Personally, I've had no luck creating a template using the Email Template entry field provided inside the SendModule menu selection.
I've searched high and low and have seen others post questions about color etc. For me, I would just like to create something tablelized that is delivered in the center of the screen.
I notice the message arrives with a great deal of formating instructions which I have read is from my theme (I use Garland Fluid). But how do I tell Send to turn that off?
I'd like to start a thread where people post what they've gotten to work so we can all learn and therefore Send becomes easier to use.
I will take on the responsibility to compile all posts into a sort of user tip guide.
Cheers!
Cozmo
Comments
Comment #1
stevensurowiec commentedThe reason for this if I remember correctly (do not have the module in front of me) is that the module passes the email body through theme('page').
Comment #2
cozzi commentedThat's what I thought from reading another post somewhere.
Is there an easy way to stop that from happening therefore giving the "Email Template" entry field the power you expect it to have?
Comment #3
stevensurowiec commentedYou would need to find where, in the code, this is happening and modify it. I can look into writing a patch that adds an option to the administration for this later tonight or tomorrow but it may take a couple days to get done due to time constraints.
Comment #4
cozzi commentedThat would be fantastic. I've been living with it for a few weeks now (since I found and turned on the module) and can certainly live with it for a few more days - especially given that it would probably take me days just to find the code you suggest I comment out.
Comment #5
stevensurowiec commentedAfter investigating this further it does not go through theme('page') it goes through theme('send_body') so if you make an override for this in your theme file then you should be able to change the theming of the body. The theme_send_body function is below.
Comment #6
cozzi commentedBefore I asked any questions with obvious answers, I wanted to try and get your suggestion to work myself, but I can not.
What is it you want me to with the above function? I have located it in send.inc and have tried commenting out sections of theme_send_body but have not gotten any good results. To find it I searched all files for the string theme_send_body and only found it once (in the form of the function definition) inside send.inc.
I am thinking you want to me comment out either something in the theme_send_body function OR comment out something in the code that calls theme_send_body - but I can not locate any other module looking to call theme_send_body?
Sorry, I've not done any real programing in many many years so please help me with just a bit more detail on what you mean by "make an override this in your theme file"?
Thank you again for your help.
Best Regards
Cozzi
Comment #7
cozzi commentedI'm still stuck on this. Can I please get just a bit of help as to what I'm suppose to do next?
thank you in advance
Comment #8
cozzi commentedMaybe I'm doing something blindingly incorrect?
Maybe I'm going about this all wrong? If my Send emails are being sent with all the theme formating should not the delivered email "look" like my site? You know, top nav with the logo, left and right navigations with the blocks. If this were the case I would probably like what is delivered BUT right now the delivered message "only" contains the node being sent (with sender's text included) - it just looks so bare.
So, my basic question - should the Send Module be sending the node AND the top, left, right, and footer blocks? If so, have I configured something incorrect?
this could be the key to my problem.
thank you again.
Comment #9
stevensurowiec commentedThe following page has information on creating and using a template.php file.
http://drupal.org/node/11811
Once this file is created you would need to create the function I posted in that file with the name [theme]_send_body where [theme] is the name of your theme (ie - garland). This function gets passed a parameter called $value and returns the actual HTML display of the email. By overriding this function you take away the module's themeing of the email body and do it all yourself.
Comment #10
cozzi commentedThank you for the added details - I will try this.
I really appreciate the extra effort here.
Cozmo
Comment #11
buddhahara commentedComment #12
buddhahara commentedI would like to change the template if possible without modifying the underlying code if possible. I am wondering what variables can be used in addition to %message and %body. Basically, I would prefer to send people a teaser and a link to the full article or maybe even just the link. The idea is to use send to drive people to the site versus send the site to them. :)
thanks
Comment #13
allie mickaI'm open to ideas ( and patches ! ) for getting more tokens into the send message templates.
One thing to keep in mind, however, is that Send is capable of sending multiple nodes in a particular message. Therefore, it gets a little messy to contemplate having %link_to_node or %node_title, etc.
You can always disable the "allow sending of full text" item to restrict sent node(s) to a teaser view.
Comment #14
cozzi commentedI’m sorry, but I just can’t seem to get this override to work for me. Here’s what I’ve done:
1) I found the file template.php (it already existed) in my folder ../theme/garland (I use garland as my theme)
2) I added the function you posted to the bottom of this template.php
function garland_send_body($values) {
$body = '';
$template .= $values['template'];
if ($values['message']) {
$message = '
';
}
$body = $values['node_body'];
$replace = array('%message', '%body');
$values = array($message, $body);
return str_replace($replace, $values, $template);
}
When testing Send to Friend the email delivered still comes with a blue background (the same color as my theme’s left and right nav) and when I view source of the email there is a lot of html markup that seems to be theme related. (same as the original post)
I also tried this process again after upgrading to the new build of Feb 25.
Now, I might be missing something, because as I’ve re-read your instructions numerous times over the past two weeks and still can't get it but there is one statement I’m not 100% sure of. What do you mean by this – “By overriding this function you take away the module's themeing of the email body and do it all yourself.” Does this mean I am suppose do something additional to the function you posted to get the override to work?
Thanks in advance
Comment #15
MauMauIn send.inc line 592 it says
If you change that to
the teaser will still get sent. But the receipient will not have to look at taxonomy links.
You can up the ante and go
If you're used to do Drupal templating you might go
You can play the same tricks on case 'body' in line 598.
node_view is the function that loads the teaser or body text that you so desperately want to alter
http://api.drupal.org/api/function/node_view/5
Unset will be your best friend.
Comment #16
cozzi commentedAllie: Is there any chance you could give us a "one" click checkbox to tell Send to "by-pass" all templating therefore giving all layout control to the Email Template field provided in the Send to Friend configuration area? You could put this checkbox just before the Email Template configuration field.
Is this possible? (Honestly, I have no idea to how to code it or I would help. I'm asking this question on behalf of the many non-coders that really struggle with things (seamingly simple to a programmer) such as the instructions I've been wrestling with above.)
Thank you in advance
Cozmo
Comment #17
amiable_indian commentedThanks this thread helped me in creating my own template for `send` module... I am a newbie to drupal but with few clicks and play around with api , I was able to get this working.
1. go to your theme folder
2. add the following function to your template.php
3. For testing, I used the following code. Its helpful when you have complicated CCK fields and want to debug your code. If you use gmail , use the "show original text" to see the actual values of the array.
Best way to tackle theming problem with 'send' module would be to have something like 'ConTemplate' :-)
HTH,
~Amiable_Indian
Comment #18
jerdavisThanks so much for the great example Amiable! I've added this to a handbook page for Send http://drupal.org/node/291748
Comment #19
steveoliver commentedThanks for the function. I found that
$body .= $values['node_body'];actually prints the node body while$body .= $node_details->body;returns nothing.