Guest User

Untitled

a guest
Jun 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Programmatic creation of a node - as simple as it gets
  5. *
  6. * All Drupal nodes require a title; everything is else is optional or
  7. * is auto-generated by Drupal upon saving the node to the database.
  8. * This node has no extra CCK fields defined; we're simply giving it
  9. * a title and a body. The author will be the super-admin user, and its
  10. * published status will be "published".
  11. */
  12.  
  13. // Create an empty object
  14. $node = new stdClass;
  15.  
  16. // Setup the basics
  17. $node->uid = 1;
  18. $node->status = 1;
  19. $node->type = 'page';
  20.  
  21. // Fill in the data
  22. $node->title = 'Results for submission ' . $something_unique_here;
  23. $node->body = 'Results: ' . $body_of_results;
  24.  
  25. // Submit the node, so validation is run
  26. $node = node_submit($node);
  27.  
  28. // Save the now-validated node to the database
  29. node_save($node);
  30.  
  31. ?>
Add Comment
Please, Sign In to add comment