By thaoehut.tahto on
I'm trying to make and save CCK nodes of type video programmatically, but when this executed, it doesn't appear to save the new node.
$node = (object) NULL;
$node->type = 'video';
$values["title"] = "the title of the video";
$values['body'] = "description of the video";
$values['field_video_url'][0]['embed'] = "http://www.youtube.com/watch?v=YgW7or1TuFk";
$values['pathauto_perform_alias'] = 1;
$values['comment'] = 2;
$values['status'] = 1;
$values['promote'] = 1;
$values["taxonomy"] = array('tags' => array('1' => ('youtube, tag2, other_tag')));
$form_state = array("values" => $values);
drupal_execute('video_node_form', $form_state, $node);
Comments
...
Several problems:
You'll need to add:
near the top, and you'll need to add:
before the $form_state assignment.
As written, this code will create the node with an owner of anonymous. You'll need to add a name to the values in order to achieve something else... perhaps:
See http://drupal.org/node/293663 for some examples.