The 1st Rules Action (which produces the data below "Part 1" in the message) just displays the entire field collection, simply by referring to token.You need (repeat: need) a Rules Condition "Entity has field" (prior to being able to use it anywhere later on in your rule), which refers to your field collection field.Here are some more details to explain the above rule: But apart from that it is similar to what you will need to specify in your Rules logic. Here is the Rule (in Rules export format) that produced the above "message": Īdmitted, this is a slightly simplified field collection configuration (no "nesting" involved). The unique ID of the field collection item: 3 The host entity of this field collection item: 43 The unique ID of the field collection item: 2 Part 2: The result of a Rules loop that iterates for each of the field collection items (using its unique ID). Part 1: The field collection with machine name 'field_treatment_details' looks like so: a boolean field labeled Betalend with machine name field_betalend. a text field labeled Doelpubliek with machine name field_doelpubliek. The machine name of the field collection is field_treatment_details, and the number of values for it is unlimited. Let's assume you want to display these data via a Rule, using Rules Action "Set message", and using Rules Event "Content is viewed", so that such message looks like so: This is a demo of a node containing a field collection. a boolean field labeled " Betalend" (Dutch for "Payable") with machine name field_betalend.Īssume a node with "some number of" field collection items, with values that look like so (with some number = 2 in this case, but that could be any number as per the "unlimited" above):.a text field labeled " Doelpubliek" (Dutch for "Target audience") with machine name field_doelpubliek.The machine name of the field collection is field_treatment_details, and the number of values for it is unlimited.Part 1: Processing field collections in a ruleĬonsider a configuration with a field collection like so: The email body of the Rules module does not seem to have the ability to "loop" over content. While I understand the example shown in the existing answer, I can't seem to conceptualize how I would be able to write a Rules "loop" to display the field collections in an email. Can anyone shed some light on the purpose of the numbers? I'm never quite sure what to select: 0, 1, 2, or, 3. I see the usage of a '0','1', '2', and '3' in the above token. Specifically, the use of what appears to be an index. On a side note, I find the field collection syntax used when working with the Rules data selector somewhat confusing. field-equip-rowers` is variable and can consist of up to 8 user names.Īny pointers in the direction of how to display the contents of the field collections in the body of an email? Do I need to write some PHP code to make this happen? If so, what's the critical piece I'm missing? That is, their fields are fixed values except forfield-equip-rowers. The contents offield-boat-lineup are consistent. Specifically, I have two field collections: field-boat-lineup and field-equip-rowers.field-equip-rowers is actually nested withinfield-boat-lineup. I've tried using what Rules gives me for data selectors, but I can't seem to put it together. Within the body of the email, I'd like to display the contents of a nested field collection. I'm trying to write a rule (using Rules) that will send an email to users of a role.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |