Hi all, I need to import 6000+ contents from a textfield. One field of old DB is my "taxonomy" so I have a table where I can associe old taxonomy with new taxonomy.
Now, my code is this:
$node = new stdClass(); $node->type = 'article'; $node->language = true; $node->uid = 1; $node->title = $fields[1]; $body = $fields[3]; $node->body = $body; $node->teaser = drupal_substr($body,0,150);
$node->field_subtitle[0]['value'] = $fields[2]; $data = substr($fields[5],0,8); $data = split("/",$data); $node->created = mktime(0,0,0,(int)$data[0],(int)$data[1],(int)$data[2]); if ($fields[6] == 'S') $node->status = 1; else $node->status = 0; $node->nodewords->keywords['value'] = $fields[7];
//TAXONOMY $tax = array(8 => 24, 9=>7,10=>6,11=>5,12=>4,13=>3,14=>10); for ($t=8; $t<15;$t++) { if ($fields[$t] == 'S') { $context['message'] .= "<br>Inserito in tassonomia ".$tax[$t]; $node->taxonomy[$tax[$t]] = taxonomy_get_term($tax[$t]); //db_query("INSERT INTO {term_node}(nid,vid,tid) values(%d,%d,%d)",$node->nid,$node->vid,$tax[$t]); } }
node_save($node);
This works, not at 100%, and my node is created, but I have a problem with taxonomy and terms (e.g. term id 24): after that I have imported a "old node" I can not see the "new node" in taxonomy/term/X, but if I click on modify and without any type of modification I save the node then this node is present in my taxonomy/term/X nodes lista. Why this ? Where is my error ?
M.