Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Programmatic creation of a node - as simple as it gets
- *
- * All Drupal nodes require a title; everything is else is optional or
- * is auto-generated by Drupal upon saving the node to the database.
- * This node has no extra CCK fields defined; we're simply giving it
- * a title and a body. The author will be the super-admin user, and its
- * published status will be "published".
- */
- // Create an empty object
- $node = new stdClass;
- // Setup the basics
- $node->uid = 1;
- $node->status = 1;
- $node->type = 'page';
- // Fill in the data
- $node->title = 'Results for submission ' . $something_unique_here;
- $node->body = 'Results: ' . $body_of_results;
- // Submit the node, so validation is run
- $node = node_submit($node);
- // Save the now-validated node to the database
- node_save($node);
- ?>
Add Comment
Please, Sign In to add comment