Image gallery within a repeat region (swiper)

I need to do the following:

I have a list of travel programs on the website home page.
Within each program I have to show the title, the program’s presentation text and a gallery of images from this program.
I can show programs with titles and text without problems within a dmx-repeat.
But I can’t show the image gallery linked to the program.

I created 3 serverconnect:
1 - sc_programa_content
2 - sc_gallery - field that links to: sc_programa_content (ID)
3 - sc_gallery_images - field that links to: sc_gallery (ID)

Within the dmx-repeat that shows the programs I created a dmx-swiper area to show the images in slides.
But in the three programs that load dmx-repeat, the slide always shows the same images.

Well… I’m a PHP developer and I can do the logic and reproduce it without any problems, but I can’t make it work in Wappler.
What am I missing here?

Hey @marcosvinicios,

I see 3 serverconnects…
**
I assume that the gallery and gallery_images are not subtables of programma_content, because it would be easier, if that’s the case and need help on that just say it.
**
You better create 1 server connect based on program_content then inner join the related gallery and then another inner join the pictures of the gallery
Don’t output that query.
Add a repeat (after the query) based on that qeury, name it programma_content and export the fields you need (title, text etc)
Then add a repeat inside the repeat and name it gallery. Here you export the images per program_content.
Ready on server side

Now on client side, you add a repeat based on programma_content, pull the basic texts & titles and then another repeat based on the gallery and pull the pictures for your swiper.

I am away from keyboard now but I can help if needed later

Hello. Thanks for getting back to us.
I even did the first repeat. The second time I had doubts. Should I use the same Expression (query) as the first repeat?
And if I choose Expression QUERY in the second repeat, should I select OUTPUT? And shouldn’t the fields from the gallery_images table appear?
Here you comment: Here you export the images per program_content.


The second (nested) repeat must have source the gallery_pictures array…

Please a screenshot of the query structure… Or export the output of your query to see the results
(first tick the output of your query!!!)

I apologize my friend for the mistaken instructions…

Here is how it is done:
(I have used for example a clients table and a client_destinations table, each client may have 1 or more destinations)
The only difference in your case is that we need one more join in order to get the pictures (because they are not related directly to the programma_content but to the gallery.

1) Database query “query” (multiple records):

  1. enable DISTINCT (not duplicate recs)
  2. programma_content table (main table)
    3a) gallery (INNER , gallery.id = programma_content.gallery)
    3b) gallery_images (INNER , gallery_images.gallery = gallery.id)
  3. add the main details of the programma_content (titles etc…)

2) repeat “programma_content” :
Repeat expression : query


Export the main programma_content fields we added in the previous step

3) Database query “gallery” :

  1. add the gallery images table
  2. add gallery (LEFT jOIN, gallery.id = gallery_images.gallery)
  3. add the fields from gallery_images you need (image name, image path etc…)
  4. set the condition for query “gallery”:
    gallery_images.gallery = repeat.gallery.id

That’s it…
You get this (imagine that clients are programma_content and client_destinations are gallery_images)

If you have questions drop it here

Hello. First of all, thank you very much for trying to help me.
Well… I tested, redid and tested again and the script can only return 1 programma_content. There are two registered in the database but only returns 1 with the gallery and images.

Code:
select distinct conteudos.whats_id, conteudos.whats_title, conteudos.whats_programa_id, conteudos.whats_content, conteudos.gallery, conteudos.whats_status from conteudos inner join conteudos_galleries on conteudos_galleries.whats_id = conteudos.whats_id inner join conteudos_gallery_images on conteudos_gallery_images.imageGalleryID = conteudos_galleries.galleryID where conteudos.whats_programa_id = ?

Hey Marcos,

This is what confuses me…

Please share a screenshot of your serveraction steps in order to start examining 1 by 1 the steps…

what conteudos.gallery is? what is in there? is this a subtable?

Hello @famousmag
It worked out.
I redid it from scratch and followed your tutorial. It worked out.
Thank you very much.

1 Like

Glad it worked!!

I don’t know if there is a easier way but that way works for sure!!

1 Like