I would like to have galleries of photos displaying in dynamic pages so I could change theri contents for each page. But in collections looks like we can only upload one image at the time. Can one title upload more images and the gallery will display these? please please!
Hi Ania,
you can write some code to do this (if it helps). You will have to insert the different pictures in your database and then you can define your gallery to read them… It worked for me!
thanks Aldino, would you mind sharing your code with me? I can’t write any
Hi Ania,
sure, here it goes:
$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},
];
});
Where:
- dataset1: is the name of your dataset;
- gallery1: is the name of your gallery
- foto_1 to foto_10: are the field names I gave to the entries in my database where I have photos. In this case my gallery is reading 10 fotos but you can change this number if you will… Also, if you have less photos, there is no problem, it will only read the one you have loaded.
I hope it helps
Best,
Aldino
PS: I also cannot code… so I do not know much more than this
Thanks so much! I 'm just having a problem with how to connect the gallery.
Do you have a separate collection for images (foto_1 - foto_2)?
And how did you connect your gallery.
I can only connect the gallery to each of the photos and it would display but only this one image.
Maybe u can explain a bit? Thank u !
Hey,
so you have a dynamic page correct, and to that page you have associated a dataset, which is connected to your collection. In this collection I have several entries for photos, which I named: foto_1; foto_2… etc
in the gallery properties, you need to conect it to your dataset. The image sources is defined by the code.
After this, it should work… I’m sorry I cannot explain myself better…
Good luck,
Aldino
thank u!! I got that correct to connect the right dataset but I just don’t know where to connect image sources is for you foto_1 ?
Sorry this is my last question.
Sorry this is so ridicilous at this point but I just can’t find a way to manage column, it only allows me to manage field. What am I doing wrong?
Thanks for all your help Aldino!!
Maybe someone from Wix team can answer this???
My guess is that it is the same thing… Have you tried it? Don’t forget that, in order to display the content you must sync the data…
maybe these will help:
https://support.wix.com/en/article/working-with-sandbox-content
Best,
Aldino
Hi Aldino
i currently used your code for dynamic gallery.
it is working and thank you so much.
this code working partially and i have 2 problems / questions about these.
$w.onReady(function imatDataset_onReady() {
let item = $w(‘#imatDataset’).getCurrentItem();
$w(‘#imatgallery’).items = [
{src: item.s1},
{src: item.s2},
{src: item.s3},
];
});
1) First question:
In the console on wix on preview i get: “Loading the code for the Imat (ID) page. To debug this code, open pw18x.js in Developer Tools.” → is this a problem? what does it mean and How can I correct it?
2) second question:
for example - >> i want to display in the gallery max. 3 images for each item but not Necessarily/Always 3. So is there a solution for this?
because In some case item has only 2 or 1 image. but when in the database are lass images for any item > gallery shows empty pictures boxes — and message in console → " Wix code SDK Warning: The src parameter of item at index 1 that is passed to the items method cannot be set to null or undefined." > > > (see screen) ________ thanks for all in advance ________
thanks
Hey
anybody here ?
Hi,
Sorry, only now I saw your messages… Unfortunately I’m afraid I’m not of great help for you… I manage to have the code working and that’s it… I do not know about debuging issues… I would guess that the first issue is related to the fact that some times you do not have an image (that it also happens for me and I have no issues with the page). As for your second question, I do not have that issue since the type of gallery I’m using does not have preview (I also have some times less images than those I set to display…). As such, maybe you can choose another type of gallery? In any case I’m sure there is a workaround… I simply do not know it.
Good luck!