1

I want to set a condition based on whether a calendar item (node that uses a date field) has repeating values set.

I can't find anything relevant in the data selector. The rule event includes "content of type" so it's not an issue related to "entity has field." The relevant field is showing up in the data selector.

Also, in addition to wanting to determine "is this a repeating date", I'd want to get access to the repeat rule (by this "rule" I mean the rule created by the date module, not the Rules module). I see no data selector for that either.

0

1 Answer 1

2

I'm not aware of any Rules Condition to check for repeating attributes. However you may possibly get it to work by using a loop within your Rules Actions, to actually check how many repeating values you actually have.

To do so, have a look at the rule included in the answer to "How to add up all items of a field collection field using Rules?". You could use a similar set of Rules Actions (combined with whatever Rules Events/Conditions you want) to simply calculate how many values you have.

For that, all you need to do is to initialize some counter to zero (before the loop starts), and then add "1" to that counter for each list item. And after the Rules Loop is finished, you invoke a separate Rules Component to which you pass the counter (= result of your calculation) as a parameter. Within that Rules Component, you can add any Rules Conditions you'd want. And in its Rules Actions you perform the actual Rules Actions you want.

It might be worth to pass your date field also as an extra parameter to the Rules Component, so that possibly you can get access (whatever you mean by that) to that "repeat rule" also.

Note (about your comment): Using node:field-time:1:value might also work, but you'd first have to do some testing with that "data field is empty". I doubt a bit what happens in the case where you only have 1 value (= node:field-time:0:value), while you would be referring to node:field-time:1:value ... In that case it might cause some type of data exception or so (not sure though, to be verified). How about some data comparison related to node:field-time:1:value, or (more "safe") using a text comparison with an appropriate RegEx?

1
  • Thanks so much. Your post made me think a lot, I checked out the links etc. Along the way, I think I found a pretty simple way to check if a node has repeating dates. Please let me know if I'm not thinking about this correctly. I'm doing: "NOT data field is empty" on: "node:field-time:1:value" (where the name of the date field is "field-time"). This simply looks to see if there is a second value for the date field, and there is, the condition is met. In my use-case it doesn't matter how many values there are. I just need to know if there is more than one.
    – Shai
    Commented Dec 22, 2016 at 18:08

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.