Multiple Repeat using three tables

Hi,

I have a stocklist of machinery I'm trying to expand on.

The working version has two tables, Categories and Machines.

The workflow is a database query of the categories and the machines are a repeat of the categories with the condition being the category ID in both tables.

I have a third table of Images which I would like to introduce so I can create a dynamic swiper of images associated with each machine record.

The images table has a field called machine_id which is populated with the ID from the Machines table.

I have added second repeat under the Machines query and then added the images table to that creating condition which has the images.machine_id equal to the machines.id

No matter what I do on my page I can't get the repeat of the images table from the workflow to show the entire array of images, it only shows the iamges for the first machine record, so I know the ID is not getting through to the images condition.
I don't know how to fix this.

My page code:

Maybe there is better and simpler way to do this, again I'm unsure.

Any help would be great.

CK

repeatimg[0].queryimages

You're always getting the first element [0], are you aware of that? You also have the same issue with the machines variable

(I can't give you a more elaborate answer because I'm not very familiar with the front-end)

I know, this is why I am asking why the images are not repeating as expected.

Because the expressions you picked are wrong.

dmx-repeat:repeat2="machines"

should be:

dmx-repeat:repeat2="repeatimg"

and then the

dmx-repeat:repeatimg="repeatimg[0].queryimages"

should be:

dmx-repeat:repeatimg="queryimages"

also, when posting code in the forum, post the code itself, not a screenshot. It's much easier to read the code directly than trying to find issues on screenshots.

If I change

dmx-repeat:repeat2="machines"

to

 dmx-repeat:repeat2="repeatimg

Then the machine detail won't show as it correctly does at the moment.

Is the way I have the two repeats in the API correct?

Is your repeat called repeatimg outputting any values? Have you selected the fields to be outputted to the front end?

No, there are no values selected.

Should I select the ID from the Machines query above?

Well select the values which you want to be available on the page. Or simply select “Exclude” and don’t add any values, this will make all the fields available on your page.

Your expressions are good, but instead of 0 you need to pass the current index like:

dmx-repeat:repeatimg="repeatimg[$index].queryimages"

If you have included the fields of the query in the repeat it would be easier and the solution of @Teodor is correct also. You did the same with the categories query. Setting the Output Filter for the repeat to Exclude and select no fields is the same as including all fields.

Thank you both for your help, you have made me realise I needed add the fields I wanted to the repeat output fields.

I renamed the repeats for clarity and everything is work as I expect.

Thank you once again.
CK