Skip to content

Instantly share code, notes, and snippets.

@investic
Created December 11, 2009 09:10

Revisions

  1. investic renamed this gist Dec 11, 2009. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. investic renamed this gist Dec 11, 2009. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Drupal Crear dos nodos con un campo en comun → PHP
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    <?
    /**
    * Implementation of hook_nodeapi().
    * Drupal Crear dos nodos con un campo en comun
    */
    function sorteo_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
    switch ($op) {
  3. investic revised this gist Dec 11, 2009. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Drupal Crear dos nodos con un campo en comun
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?
    /**
    * Implementation of hook_nodeapi().
    */
    @@ -18,4 +19,5 @@ function sorteo_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
    break;

    }
    }
    }
    ?>
  4. investic created this gist Dec 11, 2009.
    21 changes: 21 additions & 0 deletions Drupal Crear dos nodos con un campo en comun
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    /**
    * Implementation of hook_nodeapi().
    */
    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;

    }
    }