Conditions on terms
AlexisWilke - June 13, 2009 - 20:29
| Project: | Rules |
| Version: | 6.x-1.x-dev |
| Component: | Provided module integration |
| Category: | feature request |
| Priority: | normal |
| Assigned: | AlexisWilke |
| Status: | needs work |
Jump to:
Description
Hi guys,
There is a small patch to add two conditions on terms. Although one of them (i.e. comparing two terms together) may not really be achievable at this time, it is available right now!
The other condition is to test the existence of a term. Returns true if a term exists. It can be used to avoid creating the term multiple times, for instance. Or to allow/forbid something as I was thinking it could be useful to have a way to deny access to a node from the Rules module. 8-) But I'm not too sure there is a hook available for that purpose...
Thank you.
Alexis Wilke
| Attachment | Size |
|---|---|
| rules-6.x-condition_term.patch | 4.31 KB |

#1
Yep, some conditions would definitely make sense. Some points:
1. There is no need for this code comment:
+ // I suppose this cannot be achieved yet...
+ // It could be used to compare the parent of two distinct terms...
2. Code style:
Please keep array definitons in 1 line as long as the aren't longer than 80chars,
e.g. I think
+ 'term1' => array(
+ 'type' => 'taxonomy_term',
+ 'label' => t('Term 1')
+ ),
could be one line.
@rules_condition_term_exists
I think this should also take the vocabulary as argument. The problem with that is only, that as of now arguments may not be optional (again rules 2..). However I think usually the user wants to check in an existing vocabulary nevertheless, as there is no possibility to use a term from one vocabulary in others, thus I think it's ok to enforce a vocabulary argument.
This should also help to simplify the condition's code itself. :)
#2
Subscribing, I would like to be able to define a condition that checks to see if the content has been tagged with a term that is in a specific set of terms. For instance, to say "this condition is met if the content has been tagged with the terms blue, yellow, or green in the 'colors' vocabulary."
-Josh
#3
fago,
Should the user load the vocabulary in a previous rule? Or should it be hard coded? (and see the problem of variable naming I submitted...#501336: Error: variable already exists...)
Josh,
That should be doable since the comma is accepted as a separator in the taxonomy tag entry we can assume no tag would include a comma (and if it does, fix it.)
Thank you.
Alexis
#4
>Should the user load the vocabulary in a previous rule?
Yes!