3

On my site (Drupal 7/Flag 2/Rules 2), users can flag taxonomy terms. I am attempting to write a rule that compares a list of taxonomy terms that I have created with each user's list of flagged terms.

I generated the list of flagged terms by using the Fetch content flagged by user action, which provides a variable of type list of flag items. However, I cannot directly compare this with my other variable, which has a type of list of taxonomy terms, because when I iterate through the list of flagged terms using a loop in Rules, the current item from the list of flagged terms is not recognized as a taxonomy term.

Is there a way to force Rules to recognize that the flagged item in question is in fact a taxonomy term? If not, what is the nature of the list of flagged items variable?

1

The action 'Fetch content flagged by user' definitely only returns node type content. I just tested it out and sent the items provided by that action to a rule component which checked the content type. It only sent nodes, not terms, though my user definitely had flagged terms...

Here's what I did to look into it.

  1. Create a rule component: /admin/config/workflow/rules/components/
  2. Make sure it's a rule or rule set component
  3. I have mine accept 'any entity' as a parameter, because I want my original rule to supply it with the 'Fetch content flagged by user' list_item, which this component can check
  4. Eventually, you can have it accept a second parameter, which could be a list for it to add to, if the supplied entity is determined to be a type 'taxonomy term'... no need to do this yet, because we'll find out that none of the content passed is of this type. :-(
  5. Once you've set the parameters, continue to your rule, and add a condition "entity is of type". Set this to 'taxonomy term' and then in an later iteration to 'node' to compare the results of each of these settings
  6. I set the action based on the above test to be 'Show a message on the site' for now. This could have been something like 'add item to list' if the above test actually ever was true for terms.
  7. Save the rule component, and go back to your original rule where you loop through the content tagged by the user. Add an action IN your loop, in which you call the above component (components appear at the very end of the list) and provide your current list item as the component's parameter.
  8. You'll see that only flagged nodes are ever sent to the component, and never terms.

It seems that though flagging of terms was recently introduced in the Flag 2.0 module, the integration of that piece with rules is a little behind. :-(

Anyway, I hope the above helps shed some light in your situation. Let us know if you find a way around this. I've played around with it some more, and couldn't find a round-about way to get to what you need yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.