Skip to content

Instantly share code, notes, and snippets.

@investic
Created December 11, 2009 09:10
Show Gist options
  • Save investic/254101 to your computer and use it in GitHub Desktop.
Save investic/254101 to your computer and use it in GitHub Desktop.
<?
/**
* Implementation of hook_nodeapi().
* Drupal Crear dos nodos con un campo en comun
*/
function sorteo_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'insert':
//crear dos nodos de quiz relacionados por su campo de nid
if($node->type == 'quiz' && !$node->field_identificador[0]['value']){
$nid=$node->nid;
$quiz = $node;
$quiz->field_identificador[]['value']=$nid;
unset($quiz->nid);
$quiz->language='eu';
db_query("UPDATE {content_type_quiz} SET field_identificador_value = '%s' WHERE nid = %d",$nid,$nid );
node_save($quiz);
drupal_goto('admin/sorteos');
}
break;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment