I got a database field with image urls in it, separated by commas.
In appconnect I can bind these data with the following code: get_product.data.query_product.product_images.split(',')[0] get_product.data.query_product.product_images.split(',')[1]
etc…
Now I have created a table and set the table body a Repeat Children with the expression get_product.data.query_product.product_images:
I set the Image Source in the table cell to product_images, like this:
Unfortunately no images are shown in the table. Anyone an idea what I am doing wrong here?
The repeater is clearly not configured correctly, but I can’t figure out how to fix that.
What are you trying to repeat exactly? The whole database query or something else? What is your repeat expression?
Why are your image stored in a single db field - that is a really bad idea and bad database design and only causes trouobles.
Thanks for your reply. This is the repeat expression I am using for the table body:
I am trying to repeat the multiple image urls from the the single database field, so I can display every single image in a new table row cell.
However, since you mention it's bad practice to store all image urls in a single db field, what would be a better way to store them? We decided to store them in a single db field, because the images are product images and depending on the product there might be 1, 5, 20 or whatever number of images to be stored. So how can I store them better in the database so they can be shown as thumbnails in a gallery (as images in repeated table cells), no matter the number of images?
So I did this, but now I am running into another problem:
I get the data from table 1 (holding my records) from a server connect action and use them as a repeater to display all records. Of course, I want to load the corresponding images for these records and show them in the repeat regions too.
I tried 2 ways:
In the database query to load the repeat data I setup an INNER JOIN for the images table. Problem: There are several records in the images table for the respective recordID's, which results in records being duplicated in the repeat region with another image in every duplicate.
Get the images through a separate server connect action. Problem: I can't get the proper data for every repeat area.
I would say method 1 is the way to go, but I tried literally every database query JOIN option and none of them works.
Please let me know if you require more information. Thanks for any help in advance!
This was the solution I was looking for. Don’t know why I didn’t define this as a nested repeat region myself and looking it up in the docs.
One more question:
This is an example of the returned data for a single product from the queries on my page:
Now, I want to use the highlighted url value of the first image record as an image source. How do I do that? I thought get_products.data.query_products_repeat[0].query_images[0].url would dothe trick, but unfortunately that doesn’t work. Thanks in advance again for your help
Looking up the repeat region to send you a screenshot I found that I obviously had to select query_images[0].url from the repeat region data instead of from the server connect action data tree!
But this will point to the first image only.
If you want to list all images per record, then you need to nest another repeat inside and use {{query_images}} as a source, then place an image with a dmx-bind:href="url" inside it.