Community Documentation

Themeing output from Send to Friend

Last updated August 17, 2008. Created by jbrauer on August 6, 2008.
Edited by jerdavis. Log in to edit this page.

  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);
    }
    ?>

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.