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!