Themeing output from Send to Friend

Last modified: August 17, 2008 - 16:27
  1. go to your theme folder
  2. add the following function to your template.php

    <?php
    /*Templating for Send Module*/
    function YOURTHEME_send_body($values) {
     
    # send module can email multiple nodes, but my implementation sends only one..
      # so this hopefully not break anything, node_load function will grab all other details for the
      # node that the user is emailing
     
    $node_details = node_load($values['nids']['0']);
     
    ## Adding my site banner
     
    $body = '<hr /><img src="http://example.com/logo.gif" /><br />';
     
    ## adding node title
     
    $body .= '<h2><a href="http://example.com/'.$node_details->path.'">'.$node_details->title.'</a></h2><br/>';
     
    ## adding full body, you might change this to only teaser
     
    $body .= $node_details->body;


     
    $template .= $values['template'];
      if (
    $values['message']) {
       
    $message = '<div class="messages">'.check_markup($values['message']).'</div>';
      }
     
    $replace = array('%message', '%body');
     
    $values  = array($message, $body);

      return
    str_replace($replace, $values, $template);
    }
    ?>

  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.

    <?php
    /*Templating for Send Module*/
    function YOURTHEME_send_body($values) {
     
    $node_details = node_load($values['nids']['0']);
     
    ## just dump everything into email body
     
    $body = print_r($node_details,TRUE);

     
    $template .= $values['template'];
      if (
    $values['message']) {
       
    $message = '<div class="messages">'.check_markup($values['message']).'</div>';
      }
     
    $replace = array('%message', '%body');
     
    $values  = array($message, $body);

      return
    str_replace($replace, $values, $template);
    }
    ?>

 
 

Drupal is a registered trademark of Dries Buytaert.