2

I have a content type (called Issue dates with fields called field_issue_date (date type) and field_issue_type (term_reference)) and by using Rules module 7.x-2.9 I want to check if the taxonomy field has been set to "Double", If so I want to list and set the next Issue Dates content type to be unpublished e.g

"Magazine Issue Date 2017-04-07 (Double)"

"Magazine Issue Date 2017-04-14" this should now be set as unpublished

"Magazine Issue Date 2017-04-21" this should be/remain published

Note: If Rules isn't the way to go, what would be a better way to unpublish a piece of content

2
  • I've now added field_ for fields that I have included in my content type "Issue Dates". When you add new content "Issue Dates" the date and (if set to (Double)) is generated by Automatic Nodetitles 7.x-1.0 and tokens 7.x-1.7 is appended to the content title. Point 1, Rule Event if content is new or has been updated. Rule Condition if content taxonomy name has been set to "Double" Rule action then loop through all the content type (Issue dates) and if content type (Issue dates) field_issue_date is =< +7days of field_issue_date of Rule event content then set to unpublished.
    – hobbsie
    Mar 28, 2017 at 13:38
  • field_issue_type is a multiple value
    – hobbsie
    Mar 28, 2017 at 14:35

1 Answer 1

0

Have a look at this, rather basic, rule (in Rules export format):

{ "rules_check_taxonomy_term" : {
    "LABEL" : "Check Taxonomy Term",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert" : [], "node_update" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_issue_type" } },
      { "list_contains" : { "list" : [ "node:field-issue-type" ], "item" : "4" } }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "A node containing the tag [node:field_issue_type] just got created or updated." } }
    ]
  }
}

Here is what this rule does:

  • Rules Event: After saving new content, After updating existing content
  • Rules Conditions:

    • Entity has field "field_issue_type", which is the machine name of the term reference field I want to check for.
    • List contains item "node:field-issue-type" and with Taxonomy term identifier value "4" (which is the term id of the term I want to check in this Rules Condition).
  • Rules Action: Show a message on the site (which is "A node containing the tag [node:field_issue_type] just got created or updated." (with [node:field_issue_type] the actual term with term id = 4).

What is crucial in the above rules example in the context of this question, are the 2 Rules Conditions. Especially because of your extra comment "field_issue_type is a multiple value" (only "List contains item" is the Rules Condition that will do the trick ...).

Use the Rules UI to import the above rule in your site. Here are the tweaks you'll need to make it fit your case:

  • Within the Rules Conditions, adapt the "term id" (= "4") to fit your case.
  • Replace the Rules Action by what you want to happen as per the "set the next Issue Dates content type to be unpublished" in your question, which should really be a different (followup?) question.

PS: This answer applies to D7.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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