How to create different gallery in each dynamic item page

I am making a food page. One of the page shows all of the restaurants that I have visited with a cover image and restaurant name. And when I click inside, I want the dynamic item page to show the pictures from corresponding restaurants. I have successfully made the first part and created the dynamic page. However I do not know how to do the second part.

I have followed the instruction of this article. However, I failed to make it.

I have created two data base. One is called Restaurants, having the cover image and the name.


Another one is called PhotoGallery. I have set Restaurant as the reference field linked with the first one.


Afterward, in the dynamic item page, I have added a gallery and connected to the PhotoGallery. I am not sure which source should I link to cause it would be photo in the PhotoGallery like it can be two or three.


And I have input the java code as stated. Restaurant is the ID of Restaurants data set and PhotoGallery is just the same with Restaurant as the filter.


.
The preview was like this.


Is there anyone can help to provide a solution for me? Thank you.
I am not sure about if this is related. I have added all the photos to gallery as well.

Does anyone can help? Thank you.

Sorry, but i am still looking for help

Any one willing to help?

hi Sawyer

this is better for your case. see more

Hi heyimattes,

I tried to use these code, it works but the number of photos in each gallery is not the same.
Therefore, in some of the gallery in dynamic item page, it becomes grey in color.
How to solve this?

$w.onReady(function dataset1_onReady() {
let item = $w(’ #dataset1 ‘).getCurrentItem();
$w(’ #gallery1 ').items = [
{src: item.foto_1},
{src: item.foto_2},
{src: item.foto_3},
{src: item.foto_4},
{src: item.foto_5},
{src: item.foto_6},
{src: item.foto_7},
{src: item.foto_8},
{src: item.foto_9},
{src: item.foto_10},
];
});

Maybe try using repeaters to display the data?
https://support.wix.com/en/article/about-repeaters

Hi Sawyer
i am also currently looking for the solution for variable numbers of images in a dynamic gallery.

You have to check if there is an image in all records and if not jump over that one, if it is an image create that gallery item. Understand?

Did anyone figure out the code for this dynamic gallery with varying number of images?

Also having issues finding this. Code looks correct, but all I get is a blank gallery.

Did you find a solution to this? I have mine built the same and cannot get the images to populate.