0

I have been trying to figure out how to publish multiple nodes using Rules.

I have content type Parent and content type Child. When Parent is published then Child will be created/published too. This is what I have managed to do with Rules right now.

But now I have created field (list integer) to Parent. Choosing from list (value from 1-9) example value 4. Then Rules should create 4 Child nodes.

This does not work. It creates Child nodes randomly. Example choosing 9 from list it creates just one Child. And sometimes when choosing 4 from list it creates 2 Child nodes.

Apparently there is something that I dont figure out. What would it be? Any help would be appreciated.

Here is what I have in Rules right now:

Rule to publish Child nodes when Parent is published

Event:

  • After saving new content

Conditions:

  • Content is type of. Parameter: Content: [node], Content types: Parent

Actions:

  • Fetch entity by property. Parameter: Entity type: Node, Property: Choose how many Childs, Value: [node:field-number-of-childs] Provides variables: Number of Childs (number_of_childs)

  • Loop. Parameter: List: [number_of_childs] List item: Current list item (list_item)

    • Create a new entity. Parameter: Entity type: Node, Content type: Child, Title: [node:nid], Author: [node:author] Provides variables: Created entity (entity_created)

    • Save entity Parameter: Entity: [entity-created], Force saving immediately: true

Any help with this? Thanks!

0

Rules actually can loop based on array, and you have a integer only. Try Rules Array Create. Here is a issue about that.

  • Thank you! This really saved me on this. Works like a charm now! Here is what I did: Installed Rules Array Create module and removed Fetch entity by property in my Rules. Added Create array from my list field and changed it to Loop as list. And now it works! – hene Mar 2 '13 at 12:14

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.