Hey guys,
Did a couple general searches, couldn’t find the solution I was looking for, maybe I didn’t pose the question right.
What I have right now is a list of items in a page’s structure that I want to be interspersed with summaries from a page’s children. Here’s what they look like one after another…
This pulls some images from the parent page as well as summaries from the children, which is great, except what I’m looking to do here is fold the two together. I tried my hand at array_merge, but couldn’t get any results. Right now I’m working on a a while loop, but I’m not sure I’m building it right (the result may very well return an unequal number of the two content blocks).
I’m not sure I understand what exactly you want to get? If I do understand you right, then you want one image block and then the first page of the children, then the next image block and the second child page etc?
If so, you could use the nth() method on the children within the first foreach loop:
Or better yet: Count the number of structure field items first and then use a while loop if number of structure field items and number of children is likely not the same.
Okay, got a plan that works, counting each of the two block types and then switching which to pull based on what’s available.
I’m including the code I went with below, maybe a little inelegant, but hopefully it’s helpful to somebody. Thanks again @texnixe - nth() was what I wanted in this case.