I'm trying to replace one taxonomy term with another. Currently I am using "add a term" which does not overwrite the original term (even though this taxonomy is set to allow only 1 term per node). Instead, I just get multiple taxonomy terms.
I read in this post that it is possible using the option "modify taxonomy terms" http://drupal.org/node/895310
However, that option is not available to me as an action. I only have things like:
argument: Taxonomy term
Delete a term
argument: Taxonomy term
Remove a term from content
argument: Taxonomy term
This is the same under both "update existing content" or "content is going to be saved".
There is no "replace" option, nor is there a "modify taxonomy terms". This is curious to me because I'm using the same version as the one claimed to be used in the above link...
I'm sure the answer is embarrassingly simple, but I can't find it in the forums or faq.
Comments
Comment #1
itangalo commentedYou're right that there isn't an action for replacing a term in a node – at least I don't know of any such aciton.
If you want to make sure that you don't get duplicates I would recommend first removing the term from the node and then adding it again. Then you'll end up with a node with the specified term in only one copy, regardless of whether it had been tagged already or not.
Good luck!
//Johan Falk, NodeOne, Sweden
PS: I'm not maintaining the Rules module, just helping with support questions. You are welcome to ask more questions at http://groups.drupal.org/rules
Comment #2
itangalo commentedBy the way – having an action "replace term" or "add term if not already present" would be a good contribution to the Rules module. If you are interested and have some coding skills you can check out the documentation of how to develop for Rules: http://drupal.org/node/298486
Cheers!
Comment #3
melchoir55 commentedThanks for the response itangalo! I would honestly be excited to help out with adding such a feature... unfortunately my coding skills are really limited. I know enough to modify code that I see, or to add simple things to code which already exists, but my coding skills just aren't up to the level where I could do something of this scale.
Your recommendation is a good one. I've actually been trying to do that all day. My problem has been
a) rules will only allow me to "load" a single term in a rule. Presumably I need to load two terms: The term to be applied and the term that is currently set on the node so that I can pass that term to an action "remove term from node".
I figured maybe I could make two rules, one that sets the term and one that removes the old one, but I can't see any way of setting the linear order in which rules fire, so if I did this then my term removing rule will run the risk of removing the term I just added.
b)I'm not sure how to get rules to identify which term is currently set on the node. There are tokens, of course, but none of them are specific to a vocabulary (I wish to unset all terms in the "price range" vocabulary. I can't simply unset all terms because this would destroy unrelated vocabularies).
I will probably figure out b given enough time, but I'm really not sure how I can overcome a....
If you have any suggestions then they are quite welcome! I have started a rules groups discussion of the overall problem at http://groups.drupal.org/node/94214