Modulo per nuovo tipo contenuto

1 contenuto / 0 new
Modulo per nuovo tipo contenuto

Sto provando questo tutorial:

http://api.drupal.org/api/file/developer/examples/node_example.module/6

ho dei problemi su:

<?php
/**
 * Implementation of hook_insert().
 *
 * As a new node is being inserted into the database, we need to do our own
 * database inserts.
 */
function node_mail_insert($node) {
 
db_query("INSERT INTO {node_mail} (vid, nid, from, received, to, subject, content_type, message_id, content, mail) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $node->vid, $node->nid, $node->from, $node->received, $node->to, $node->subject, $node->content_type, $node->message_id, $node-> content, $node->mail);
 
?>

Se vado a inserire un nuovo nodo mi ritorna

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from, received, to, subject, content_type, message_id, content, mail) VALUES (18' at line 1 query: INSERT INTO default_node_mail (vid, nid, from, received, to, subject, content_type, message_id, content, mail) VALUES (18, 18, 'andiamo', 'andiamo', '', 'andiamo', '', '', 'andiamo', 'andiamo') in /var/www/testing/drupal6/sites/default/modules/node_mail/node_mail.module on line 212.

Non capisco cosa sbaglio nella sintassi della query...
Il contenuto nella tabella node viene inserito, ma non nella tabella node_mail che ho creato io.

come faccio a farmi ritornare tutto l'sql della query che fa per poterlo verificare?

inoltre quesot è l'hook form

<?php
/**
 * Implementation of hook_form().
 *
 * Now it's time to describe the form for collecting the information
 * specific to this node type. This hook requires us to return an array with
 * a sub array containing information for each element in the form.
 */
function node_mail_form(&$node) {
 
// The site admin can decide if this node type has a title and body, and how
  // the fields should be labeled. We need to load these settings so we can
  // build the node form correctly.
 
$type = node_get_types('type', $node);
  if (
$type->has_title) {
   
$form['title'] = array(
     
'#type' => 'textfield',
     
'#title' => check_plain($type->title_label),
     
'#required' => TRUE,
     
'#default_value' => $node->title,
     
'#weight' => -5
   
);
  }
  if (
$type->has_body) {
   
// In Drupal 6, we can use node_body_field() to get the body and filter
    // elements. This replaces the old textarea + filter_form() method of
    // setting this up. It will also ensure the teaser splitter gets set up
    // properly.
   
$form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
  }
// Now we define the form elements specific to our node type.
 
$form['from'] = array(
   
'#type' => 'textfield',
   
'#title' => t('From'),
   
'#default_value' => isset($node->from) ? $node->from : '',
  );
// Now we define the form elements specific to our node type.
 
$form['received'] = array(
   
'#type' => 'textfield',
   
'#title' => t('Receive'),
   
'#default_value' => isset($node->received) ? $node->received : '',
  );
// Now we define the form elements specific to our node type.
 
$form['to'] = array(
   
'#type' => 'texfield',
   
'#title' => t('To'),
   
'#default_value' => isset($node->to) ? $node->to : '',
  );
// Now we define the form elements specific to our node type.
 
$form['subject'] = array(
   
'#type' => 'textfield',
   
'#title' => t('Subject'),
   
'#default_value' => isset($node->subject) ? $node->subject : '',
  );
// Now we define the form elements specific to our node type.
 
$form['content_type'] = array(
   
'#type' => 'texfield',
   
'#title' => t('Content type'),
   
'#default_value' => isset($node->content_type) ? $node->content_type : '',
  );
// Now we define the form elements specific to our node type.
 
$form['message_id'] = array(
   
'#type' => 'texfield',
   
'#title' => t('Message id'),
   
'#default_value' => isset($node->message_id) ? $node->message_id : '',
  );
// Now we define the form elements specific to our node type.
 
$form['content'] = array(
   
'#type' => 'textarea',
   
'#title' => t('Content'),
   
'#default_value' => isset($node->content) ? $node->content : '',
  );
// Now we define the form elements specific to our node type.
 
$form['mail'] = array(
   
'#type' => 'textarea',
   
'#title' => t('Mail'),
   
'#default_value' => isset($node->mail) ? $node->mail : '',
  );
  return
$form;
}
?>

ma nella pagina di aggiunta del nodo
i campi
to
message_id
content_type
non appaiono...
ho sbagliato nella sintassi?