insert taxonomy through computed field or php code?

eggthing - June 13, 2008 - 23:07

I'd like to have the authors name automatically created as a term for bio. NAT won't work as the created term doesn't link to the bio. I tried experimenting with computed field just to create a term using this code

db_query("INSERT INTO term_data (tid, vid, name, description, weight) VALUES ('', 1,'someterm','', 0)");

This nearly worked. The term appears in the term_data table in mysql but not as a term in Drupal's vocabulary.

Afterwards when I try to add a term from the add terms form in Drupal, I get in error and then term which I tried unsuccesssfullly to insert using computed field then magically appears!

Any idea of code I can use to add a term to a vocabulary from computed field?

Once I get this accomplished I should be able to substitute the authors name using a variation of this code:

global $user;
$node_field_item['value'] = $user->name;

Any luck with this? I am

jimi089 - July 21, 2008 - 03:41

Any luck with this? I am trying to accomplish the same thing!

CF Handbook

lordgilman - August 19, 2008 - 03:49

I've posted my solution as a snippet here in the Computed Field handbook.

 
 

Drupal is a registered trademark of Dries Buytaert.