[support] Node, taxonomy and no entry for taxonomy/term/X
Michel Morelli
michel at ziobuddalabs.it
Wed Jun 16 20:24:30 UTC 2010
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.
--
Michel 'ZioBudda' Morelli michel at ziobuddalabs.it
Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 -- Fax: +39-0291390660
http://www.ziobudda.net ICQ: 58351764
http://www.ziobuddalabs.it Skype: zio_budda
http://www.ziodrupal.net MSN: michel at ziobuddalabs.it
JABBER: michel at ziobuddalabs.it
More information about the support
mailing list