By darrian on
Does anyone know if/how I can create a new term for an existing taxonomy inside the code? ie NOT having to use the form to create a new term?
Thanks, Darrian
Does anyone know if/how I can create a new term for an existing taxonomy inside the code? ie NOT having to use the form to create a new term?
Thanks, Darrian
Comments
Look in th e code
I've not done it, but I imagine looking at the code in the taxonomy.module would be instructive. Find this method: [?
function taxonomy_save_term($edit)
?]
- Robert Douglass
-----
visit me at www.robshouse.net
Thanks
It looks like this is what I need. For anyone else interested, $edit is an array that contains data for the term.
I think these are the elements you need:
$edit["tid"] # leave blank to create a new term.
$edit["name"]
$edit["description"]
$edit["vid"] # id of vocab this term belongs to
$edit["weight"]
$edit["relations"] # array of tid's for related terms
$edit["parent"] # array of tid's that are parent terms
$edit["synonyms"] # array of strings that are the name of synonyms
look at artist module
look at the code of artist.module, it creates a node that becomes also a taxonomy term.
probably it is not exactly what you want, but you can use the code in a different way.
it fundamentally uses node_api to synchronize taxonomy.
hope it helps
matteo