How to create a node programaticly in drupal5 (basic version)
On:
Tuesday, October 21, 2008 - 15:10
This piece of code imports a basic node into drupal.
function create_node() { $node_to_save = new stdClass(); $node_to_save->nid = 0; $node_to_save->uid = 1; $node_to_save->type = 'product'; $node_to_save->created = time(); $node_to_save->title = 'title'; $node_to_save->body = strval('body'); $node_to_save->teaser = node_teaser($node->body); $node_to_save->filter = variable_get('filter_default_format', 1); $node_to_save->status = 1; //optional if you have cck fields do them this way $node_to_save->field_something = array(array('value' => 'something')); node_save($node_to_save); }
Add new comment