Update Drupal node programmatically, add node to taxonomy term
[b]How to update Drupal node programmatically, from your PHP script using Drupal API[/b]
This example function will update node and add it to the desired taxonomy term.
function add_teasers_to_term($tid, $nid){
$node = node_load($nid);
// we need to check if node is in the taxonomy already, so build array of term ids for this node
foreach($node->taxonomy as $key=>$value){
$nodes_taxonomy[] = $key;
}
print_r($nodes_taxonomy);
// first check if node is already in there
if (in_array($tid, $nodes_taxonomy)){
return ' node already in '.$nid;
}
else {
$node->taxonomy[] = $tid;
node_save($node);
return ' node saved '.$nid;
}
}

Comments
BOISE, Idaho (AP) — A small
China's central bank, the
Every louis louis vuitton
As soon as theabercrombie and
Every louis louis vuitton
Every louis louis vuitton
Value sensible it can be
"Is the locations of." The
"Is the locations of." The north face of excitement rushed to the precepts of north face apex bionic jacket the Central control room, and then a crystal embedded in north face apex the operating table down to the store and this thing is discipline of the ring controller. Equivalent? What? through its remote? urgent ditch Shao back to the brain vulgar? of course, can use this stuff for only the north face and the Bank may specify several players.
"Is the locations of." The
"Is the locations of." The north face of excitement rushed to the precepts of north face apex bionic jacket the Central control room, and then a crystal embedded in north face apex the operating table down to the store and this thing is discipline of the ring controller. Equivalent? What? through its remote? urgent ditch Shao back to the brain vulgar? of course, can use this stuff for only the north face and the Bank may specify several players.
WHITE LAMBS SELL TOP QUALITY,
2011-08-24_11-15-55 ->
WHITE LAMBS SELL TOP QUALITY,
You may be asking yourself,
Very usefull blog. i will
Umm, you're missing a
Umm, you're missing a close-brace '}' at the end to close the function.
Otherwise a very useful function! Thanks!
added brace, thanks for
added brace, thanks for pointing out
Darko