I have in my home page two logos that I would like to use as links to category page. Clicking on each logo I want to filter categories to Category page using script. How?
You will need something into this direction…
import WixData from 'wix-data'
let DATABASE = "your Collection-ID here";
let dbFields = [];
$w.onReady(()=>{console.log('Page ready...);
$w('#myLogo1IDhere').onClick(async()=>{
console.log("Logo-"+event.target.id+"-clicked.");
dbFields[0] = "ENTER CURRENT DB-FIELD-ID-here";
let data = await filterProcess(dbFields[0], value);
console.log(data);
});
$w('#myLogo2IDhere').onClick(async()=>{
console.log("Logo-"+event.target.id+"-clicked.");
dbFields[1] = "ENTER CURRENT DB-FIELD-ID-here";
let data = await filterProcess(dbFields[1], value);
console.log(data);
});
});
function filterProcess(dbField, value) {
return wixData.query()
.eq(dbField, value)
.find()
.then((res)=>{return res.items})
.catch((err)=>{console.log(err);});
}
Try to complete this, to get your function.
Take a look onto the RESULTS in the CONSOLE.