[support] Inserting a new taxonomy and adding a node in this taxonomy
Marc Poris
marc at funnymonkey.com
Mon Feb 26 15:52:48 UTC 2007
Carlos,
To insert the new taxonomy term you'll probably want to call
taxonomy_save_term(&$form_values) which is what gets called when
submitting the taxonomy term form. You'll need to fake the form_values
data, and you won't want to provide a tid so that one gets generated for
you.
To have your node appear within the term, you can probably call
taxonomy_node_save($nid, $terms) or fill in $node->taxonomy if you know
that your hook_nodeapi will be called before taxonomy's hook_nodeapi
(you can set the weight of your module to be lower than taxonomy's)...
I hope that gives you somewhere to start,
Marc
Carlos Rincón wrote:
> Hi all,
>
> i need to add in the fly a taxonomy to a book. I've put an extra field
> in my book (a cck node) in case the user want to add a new taxonomy
> without going to the form taxonomy.
>
> I've a custom module to handle this:
>
> function source_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
> switch ($op) {
> case 'submit':
> if ($node->type == 'content_libro') {
> echo "Nuevo Autor: " . $node->field_nuevo_autor[0]["value"];
> }
> break;
> case 'insert':
> break;
> case 'update':
> if ($node->type == 'content_libro') {
> echo "Nuevo Autor: " . $node->field_nuevo_autor[0]["value"];
> }
> break;
> case 'view':
> break;
> }
> }
>
> (This is from drupal.org)
>
> Now i need to create the taxonomy and then to put the book node in this
> taxonomy. I suppose it can be done with taxonomy_nodeapi o something
> similar but i'm newby in Drupal.
>
> thanks in advance,
>
More information about the support
mailing list