I would like to create selection tags based on data in my database. Is there any way to do this? Thanks so much!
Regards, Stefan
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
This code worked great for me.
import wixData from 'wix-data'; wixData.query("ID OF COLLECTION", ) .find() .then((results) => { if (results.items.length > 0) { let repData = results.items; let result1 = repData.map(({ FIELD ID }) => FIELD ID) const propertyValues = Object.values(result1); console.log(propertyValues); let options = []; for (let b = 0; b < result1.length; b++) { options.push({ label: result1[b], value: result1[b] }) } $w("#SELECTION TAG ID ON PAGE").options = options } })
//Selection tags selection
wixData.query("collectionID", )
.find()
.then((results) => {
if (results.items.length > 0) {
let repData = results.items;
let result1 = repData.map(({ title }) => title)
const propertyValues = Object.values(result1);
console.log(propertyValues);
let options = [];
for (let b = 0; b < result1.length; b++) {
options.push({ label: result1[b], value: result1[b] })
}
$w("#selectionTags1").options = options
}
})
If you create a tags field in your dataset, you can easily add your tag word or words to that field and use that to filter your dataset on the page.
You can see more in this previous forum post, the Selection Tags example and Selection Tags from the Wix API Reference.
https://www.wix.com/corvid/forum/news-announcements/new-feature-selection-tags
https://www.wix.com/corvid/example/filter-with-multiple-options
https://www.wix.com/corvid/reference/$w.SelectionTags.html
Hello Stefan,
what do you mean, when you say "selection-tags" ?
How does it looks like?
Can you make/show an example? (pic?)