Skip to main content

Home/ Drupal for Developers/ Group items tagged programmatic nodes

Rss Feed Group items tagged

Daniel Gregoire

Programmatically create a CCK node | Eric's Drupal Blog - 6 views

  •  
    Programmatic CCK nodes: node properties.
Daniel Gregoire

How To Create Users Programmatically In Drupal 6.x - 1 views

  • <?php $newUser = array( 'name' => 'username', 'pass' => 'password', // note: do not md5 the password 'mail' => 'email address', 'status' => 1, 'init' => 'email address' ); user_save(null, $newUser); ?>
  •  
    Create users programmatically. A bit less involved than creating nodes; you just need to populate an array with values, don't need to cast it into an object.
Daniel Gregoire

Programmatically Create, Insert, and Update CCK Nodes | doug | CivicActions - 2 views

  • Always use content_database_info to get the database info. For example:   $field1 = content_database_info(content_fields('yourfield1', 'yourtable'));  $table1 = $field1['table'];  $column1 = $field1['columns']['value']['column'];  $field2 = content_database_info(content_fields('yourfield2', 'yourtable'));  $table2 = $field2['table'];  $column2 = $field2['columns']['value']['column'];  if ($table1 == $table2) {    $sql = "SELECT n.*, t1.$column1, t1.$column2 FROM {node} n ";    $sql .= " INNER JOIN {$table1} t1 ON t1.nid = n.nid AND t1.vid = n.vid";  }  else {    $sql = "SELECT n.*, t1.$column1, t2.$column2 FROM {node} n ";    $sql .= " INNER JOIN {$table1} t1 ON t1.nid = n.nid AND t1.vid = n.vid";    $sql .= " INNER JOIN {$table2} t2 ON t2.nid = n.nid AND t2.vid = n.vid";  }  $sql .= " WHERE n.nid = %d";
  •  
    Important point: Using special functions to let CCK get the proper name of the field (allowing users to make CCK changes in the UI and let your code continue to work).
Daniel Gregoire

Configuring settings using drupal_execute | drupal.org - 0 views

  •  
    Tagged for D5, but has D6 examples. Using drupal_execute (to be called drupal_form_submit in D7) to set site settings programmatically.
Daniel Gregoire

Programatically creating a CCK field in Drupal 6 | drewish.com - 5 views

  •  
    Quick 'n' easy, create CCK fields programmatically
Daniel Gregoire

node_example.module | Drupal API - 0 views

  •  
    Basic creation of programmatic custom content type
Daniel Gregoire

Programatic CCK Now Possible! | groups.drupal.org - 2 views

  • <?phpfunction mymodule_enable() {     // Get the files content   $filename = drupal_get_path('module','mymodule') . "/mymodule.cck";  $content = implode ('', file ($filename));      // Build form state    $form_state = array(       'values' => array(            'type_name' => '<create>',            'macro' => $content,      ),     );    // Put it in there     drupal_execute("content_copy_import_form", $form_state);}?>
  •  
    Start with comment 54181 - "This works for me in Drupal 6" and read along.
Daniel Gregoire

drupal_execute | DrupalContrib - 0 views

  •  
    Actual documentation for drupal_execute
1 - 10 of 10
Showing 20 items per page