does anyone know how to create node reference while creating node programmatically? I mean - using TITLE and TYPE, not nid.
I am creating nodes via python script and user is prompted for title of parent node. Nobody's gonna tell you NID in that case. But content type and part of title should be enough.
If there is no way of doing that in Drupal - I am gonna make my own function to fetch all nodes that fits criteria and go further if there's only one or prompt for choosing proper one if there's more than one..
I'll be happy if there's already something that handles my task.. :)
My current code with doing that by NID:
$n = new stdClass();
$n->type="project_release";
node_object_prepare($n);
$n->title = "Kaboom [".date(YmdHis)."]";
$n->language = LANGUAGE_NONE;
$n->uid = 1;
$n->body[$n->language][0]['value']="12345";
$n->body[$n->language][0]['summary']="123457890";
$n->body[$n->language][0]['format']="filtered_html";
$n->field_release_project[$n->language][0]['nid']=85;
$n->field_project_release_notes[$n->language][0]['value']='AaAAAAAA...';
$path = 'remotely_added_at_'.date('YmdHis');
$n->path = array('alias'=>$path);
if($n=node_submit($n)) {
node_save($n);
echo "</br>Node with nid ".$n->nid." saved\n";
}
Cheers