Load term by name
| Project: | Rules |
| Version: | 6.x-1.x-dev |
| Component: | Provided module integration |
| Category: | feature request |
| Priority: | normal |
| Assigned: | AlexisWilke |
| Status: | needs work |
Hi guys,
There is my current solution to support loading terms by name. It is just impossible to know the term identifier when all you do is assign a name to them!
This patch offers the simple solution of starting the term_text by "name:" to ask for a term by name. For instance, if you assign a term using a node identifier, you could write something like this:
name:node-[node:nid]
So the term for node 7 would simply look like "node-7".
I do not think much of this solution but I need to know what you'd like to do.
A better (cleaner?) solution would be:
1. The drop down selection includes "Term by ID", "Term by Name", "term 1", "term 2", ...
2. When loading, check for the special cases:
a. "Term by ID", use term_text as an identifier
b. "Term by Name", use term_text as a name
c. "term 1", "term 2", ... load that term (we've got the identifier)
I'll be happy to provide a new patch for that functionality.
Thank you.
Alexis Wilke
| Attachment | Size |
|---|---|
| rules-6.x-named_term_term.patch | 926 bytes |

#1
Just in case, there is also a small change to the form.
#2
Hm, why can't you use the usual taxonomy form selector when you know the name?
I'm not sure about adding this either - as the name doesn't identify the term, there might be multiple terms with the same name. Thus there would be potentially multiple matching terms.
However if added, we would have to inform the user about it with a help text. Then I think we should just add a separate text field, e.g. like the user load action does (id+name).
#3
I use that for my users. So if user 34 creates a node, I want to assign to that node the tag "user-34". I know the name, but it is dynamic since any one user who has the right to create those nodes may do so.
Note also that the term number is not known, so I cannot use the number (user #34 may have term #107).
Another note: that term will be created whenever the user is created. That works fine since I can declare the name of the new term (i.e. "user-[user-uid]".) But then I cannot use it later unless I can load it by name. These terms are 100% dynamic!
FYI, I use those in link with the TAC Lite module to enforce very a specific access to nodes created by different people.
And I'm fine to add another field. It seems quite complicated to me, but that's okay, it will work as well.
Thank you.
Alexis Wilke
#4
hm, yes I see the need for that, so a patch is welcome.. :) But please add a good help text explaining that there might be multiple terms with that name and that rules just chooses the term among them randomly. Also yes, just add a separate field - best visible already in the first step...