Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I need another way of term manipulation. I want to replace a term or more for a node but there are allready terms from other vocabularies assinged. I don't want to kick them, I just want to delete all term of the vocabulary and add the new term.
For example: i use taxonomy for navigation and now i want to move some nodes from one category to another.
I allready realized that feature. I added the following to the function 'taxonomy_action' in taxonomy_action.inc
at line 6
define('TAXONOMY_ACTION_REPLACE_IN_VOC', 3);
at line 19:
// check for replace inside vocabulary
if ($context['do'] == TAXONOMY_ACTION_REPLACE_IN_VOC) {
$existing_terms = taxonomy_node_get_terms($node);
// delete terms in voc
foreach($existing_terms as $existing_term) {
foreach($terms as $term) {
if ($term->vid == $existing_term->vid) {
unset($existing_terms[$existing_term->tid]);
}
}
}
$terms = array_merge($terms, $existing_terms);
}
i attached the full edited taxonomy_action.inc as txt
Comment | File | Size | Author |
---|---|---|---|
taxonomy_actions.inc_.txt | 3.33 KB | JeschMB |
Comments
Comment #1
infojunkieApplied to both D5 and D6 dev. Thanks for your contribution.