I had been posting here: https://www.wix.com/code/home/forum/questions-answers/load-gallery-from-dataset
got the answer that solution would be here: https://www.wix.com/code/home/forum/questions-answers/dynamic-gallery
I tried for some days but I can not make this work
detail: i need a code i can copy and paste, i am not sufficiently familiar with coding.I understand each code needs minor adjustments depending on my personal field names etc. I really tried my best, but before abandoning this project I wonder if someone could fix me up with this code and paste it in my site i am building I understand it is not more than a 10 liner…
what I have: an index page with a gallery with +/-100 images. each image is a link to a dynamic page which generates some text info about the project(image from index gallery) and a gallery with 3 to 10 images, depending on the project. everything is set up and working. pages are loading with the correct data except for the gallery which is for now filled with place holder images. in my database I have added 4 image columns for testing. as I said this number is not the same for each generated gallery. I believe no gallery will have more than 12 images.
for now i have only linked the first 4 images of the index gallery to this dynamic page. all other images still link to pages made “manually”, which was a mistake…am learning…:).
will greatly appreciate help to get this site working. i believe for a "professional its a piece of cake and done in a flash. would be happy to return the favour. could give helpful advise on woodworking (that’s what my profession and website is about as you can see.
thanxxx
Guess not… I am used to ubuntu and linux forums…defenitely more help and answers amongst those people… whatever, guess I’ll have to find answers somewhere else
Hello Frank,
You can achieve that without code.
First, populate the collection with the relevant images. Right now it is not possible to add more than one image per field (we are working on this feature) therefore you should add the required number of image fields (image1, image2, image3 etc.).
Next, click the gallery > choose the connection menu > under ‘image source’ select the main image field > under ‘Links connect to’ select the dynamic page. Using this method will save you time in the future since you will only need to handle the image collection to add/remove gallery images. Linking new records to the dynamic page will be done automatically once you add a new item.
To finish the process, in your dynamic page, either add a number of standalone image elements (using placeholder image) and connect each one to each image field from your collection (image1, image2 etc…)
You can also write a piece of code to grab all the images from the current item to display them in a single gallery for consistency:
$w.onReady(function () {
let imageArr = [];
let item = $w('#dynamicDataset').getCurrentItem();
Object.keys(item).filter((key => {
if (key.includes("image", 0)) {
imageArr.push({"src": item[key]})
}
})
);
$w('#gallery1').items = imageArr;
});
thanks!!, due to a lack of earlyer responses i spent 2 days colonizing 33 pages with content manually…:(.
the idea of linking to standalone images won’t work for me as i want the created gallery on the dynamic page with the expand function, in order for the user to skip through in fullscreen slide mode.
so i will have to use your code example.
i will prepare a database outside wix using open office base as this goes faster and then upload in one go when i have some time to redo the work with a dynamic page in the way you suggest… i understand the only format for databases wix can handle is the csv format, right?
thanks and when i get to it i will let you know how things turned out. I appreciate your help
ok. did a quick test with the code you posted. I get following error message:
TypeError: $w(…).getCurrentItem is not a function
this is the code to that error message:
$w.onReady( function () {
let imageArr = [];
let item = $w(‘#PROYECT-DATA-Items’).getCurrentItem();
Object.keys(item).filter((key => {
if (key.includes(“image”, 0)) {
imageArr.push({“src”: item[key]})
}
})
);
$w(‘#gallery1’).items = imageArr;
});