Web site development - Open Source CMS Drupal, LAMP, PHP, Oracle. In France & on the internet everywhere

Update Drupal node programmatically, add node to taxonomy term

How to update Drupal node  programmatically, from your PHP script using Drupal API

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

Hi there, I dont know if I am

Hi there, I dont know if I am writing in a proper board but I have got a problem with activation, link i receive in email is not working... http://www.i-chaumiere.com/?6a0ccf1df04edc645f6acb8659c,

Hi there,what problem are you

Hi there,

what problem are you having exactly?  are you trying to activate an account here?  let me know what it is you want and i'll see if we can solve the problem.

Mail me at info@i-chaumiere.com.

thanks admin