background image
HomeRecent PostsDrupalSearchTagsRSSContactAboutAccount
Eric.London's picture

This code snippet will add a collapsible fieldset containing a preview of the node you are attempting to delete.

<?php
function MYMODULE_form_alter($form_id, &$form) {
  if (
$form_id == 'node_delete_confirm') {
   
$form['nodePreviewFieldset'] = array(
     
'#type' => 'fieldset',
     
'#title' => 'Preview',
     
'#weight' => 10,
     
'#collapsed' => TRUE,
     
'#collapsible' => TRUE,
    );
   
   
$form['nodePreviewFieldset']['nodePreview'] = array(
     
'#value' => node_view(node_load(arg(1)), TRUE, FALSE, FALSE)
    );
  }
}
?>

Here's a screenshot:

Eric.London's picture

Although I am a big fan of the Drupal Forms API, sometimes I'll use CCK node forms as a quick and flexible alternative. This allows you to store the user submitted data as well as process the form. Here is a code snippet you can add to send the html generated from the node in an HTML email...

<?php
function MYMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if (
$node->type == 'MYNODETYPE' && $op=='insert') {
   
$emailTo = variable_get('site_mail', 'MYEMAILADDRESS');
   
$emailFrom = 'info@' . $_SERVER['HTTP_HOST'];
       
   
// send email
   
_MYMODULE_send_node_email($node, $emailTo, $emailFrom);
       
  }
   
}

function
_MYMODULE_send_node_email(&$node, $emailTo, $emailFrom) {

  require_once(
'Mail.php');
  require_once(
'Mail/mime.php');

 
// create node html
 
$html = node_view($node, TRUE, FALSE, FALSE);
   
 
// get a list of node types
 
$nodeTypes = node_get_types();
   
 
$crlf = "\n";
 
$hdrs = array(
   
'From'    => $emailFrom,
   
'Subject' => $nodeTypes[$node->type]->name . ' Submitted',
  );
   
 
$mime = new Mail_mime($crlf);
 
//$mime->setTXTBody($text);  //TODO: you should also include a text version of your email
 
$mime->setHTMLBody($html);
 
$body = $mime->get();
 
$hdrs = $mime->headers($hdrs);
 
$mail =& Mail::factory('mail');
 
$mail->send($emailTo, $hdrs, $body);  

}
?>

Syndicate content