1) You did not pay attention!!!
Your code is UPGRADING every-time → that means it also changes!
Take a look at your last provided code and compare it with this one…
$w.onReady(async function () {
let slidesData1 = await getSlideshowDataFromDatabase("ServicesSlides", "group", "????");
console.log("Slide-Show-Data-1: ", slidesData1);
// let slidesData2 = await getSlideshowDataFromDatabase(DATABASE, DB_FIELD, VALUE);
// console.log("Slide-Show-Data-2: ", slidesData2);
feed_SlideshowWithData(slidesData1, "HomeSlideFull");
// feed_SlideshowWithData(slidesData2, SlideShowID);
//---------------------------------------------------------
});
function getSlideshowDataFromDatabase(DATABASE, DB_FIELD, VALUE) {//nothing to change here!
return wixData.query(DATABASE) //<--- Quering in which DATABASE?
.eq(DB_FIELD, VALUE) //<-- FILTERING in which FIELD? For which VALUE?
.find().then(results=> {console.log("Results: ", results);
let items = results.items; console.log("Items: ", items);
return (items);
}).catch((err)=>{return (err);});
}
//---------------------------------------------------------
function feed_SlideshowWithData(slidesData, SlideShowID) {//nothing to change here!
const slideElements = $w(SlideShowID).slides;
console.log("Slide-Elements: ", slideElements);
for (let i = 0; i < slideElements.length; i++) {
const slideElement = slideElements[i];
console.log("Slide-Element: ", slideElement);
if(slidesData.videoHome){
$w('#'+slideElement.id).background.src = slidesData[i].videoOnline;
}
else {$w('#'+slideElement.id).background.src = slidesData[i].imageOnline;}
}
}
//---------------------------------------------------------
Starting from the first lines…your code…–> your VALUES
let slidesData1 = await getSlideshowDataFromDatabase("ServicesSlides", "group");
console.log("Slide-Show-Data-1: ", slidesData1);
Did you placed the VALUES the right way?
What do expect the → getSlideshowDataFromDatabase ← function ? Which VALUES ?
Here the original second (not filled one)…
let slidesData2 = await getSlideshowDataFromDatabase(DATABASE, DB_FIELD, VALUE);
Did you use your CONSOLE, to investigate the RESULTS of this first process?
Were the RESULTS your expected ones, or did you already got an ERROR after first 1-3 code lines?
- You do not have to replace VARIABLES within the FUNCTION itself with VALUES!
For example here… I will mark the wrong parts, which should NOT have been changed!
function getSlideshowDataFromDatabase("ServicesSlides", "group") {
return wixData.query("ServicesSlides") //<--- Quering in which DATABASE?
.eq("group", "Group A") //<-- FILTERING in which FIELD? For which VALUE?
.find().then(results=> {console.log("Results: ", results);
let items = results.items; console.log("Items: ", items);
return (items);
}).catch((err)=>{return (err);});
}
It should stay originaly like this…
function getSlideshowDataFromDatabase(DATABASE, DB_FIELD, VALUE) {
return wixData.query(DATABASE) //<--- Quering in which DATABASE?
.eq(DB_FIELD, VALUE) //<-- FILTERING in which FIELD? For which VALUE?
.find().then(results=> {console.log("Results: ", results);
let items = results.items; console.log("Items: ", items);
return (items);
}).catch((err)=>{return (err);});
}
The DATA will be pulled from …THIS IS THE PART WHERE TO FILL OUT THE VALUES!
let slidesData2 = await getSlideshowDataFromDatabase(DATABASE, DB_FIELD, VALUE);
3x - VALUES are expected! → 1) DATABASE 2) DB_FIELD 3) VALUE
I would reccomend you first to bring → ONE Slideshow to work, then dublicate code-lines to generate identical working Slideshow, but with different VALUES/Parameters.
Correct this one…
let slidesData1 = await getSlideshowDataFromDatabase("ServicesSlides", "group", "????");
- From which DATABASE you want to load your items for first Slide-Show?
- In which DB-Field should take place the FILTERING?
- Which VALUE has to be filtered?