Okay, I’m pretty new to this whole thing, but fairly good at picking up new skills when I understand how they work.
I want to create a website where people can submit data, which is then easily searchable and filterable, and displayed on a dynamic page. I have set up a dataset and form submission page, whereby tags can be added to multiple fields for the submitted item through multiple selection checkboxes. What I want to be able to do, is to display those submitted tags as a text list on a dynamic page. I was wondering if either this is doable directly, or I can have a concurrent text field that will contain those tags in list form?
I also have the question as to whether tag fields are searchable/filterable?
And if you filter through check boxes, can you have a drop down menu to change the filter from AND to OR? So you could have multiple filters, and search like so: (1 OR 2) AND (x OR y). But could change the first filter to AND, so the search would be: (1 AND 2) AND (x OR y).
Sorry if this is worded terribly, or I’m missing something terribly simple. I feel really close to having what I’m after, and hope you can help.
You can filter/query with AND & OR…
Have a look to the API: https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html
Everythink you wanna do should be possible. Just need to understand the Corvid-API and JavaScript.
Hi, I appreciate the reply, and am glad to know this is possible.
I’m concerned I might be missing something simple though.
I’ve been looking into it, and have still got nowhere with figuring out how to display the value of a tags field in a list/text form, or copy the tags data to a text field. I am able to display the tags through a multiple selection box however - is it possible for the unchecked options to be hidden?
I’ve also been able to set up a multiple selection box filter that searches a tags field, and I’m confident I could have that work in tandem with another, but it only brings results if all values are matched, rather than any values. Is there any way to change that?
@rackabello
Well you can be lucky. I worked the last days on the same problem and solved it.
The think is to fix this problem: “only brings results if all values are matched, rather than any values.” you have to use Multiple-Item References. That was for me only way to reach it - with the function include()
An example from my project
Collection “ExcursionsDB” with the Multiple-Item References (Region, Langue, Responsable)
So first show you how to Display it as Text:
Display Mutiple-Item References as Text
import wixData from 'wix-data';
$w.onReady(function () {
$w("#dynamicDataset").onReady(async () => {
const itemObj = $w("#dynamicDataset").getCurrentItem();
$w('#regionView').text = await fillText(itemObj._id, "ExcursionsDB", "region");
$w('#langueView').text = await fillText(itemObj._id, "ExcursionsDB", "langue");
$w('#themeView').text = await fillText(itemObj._id, "ExcursionsDB", "themeActivites");
$w('#guideView').text = await fillText(itemObj._id, "ExcursionsDB", "responsable");
$w('#guideNrView').text = (await wixData.query("GuidesDB").eq("_id", itemObj.responsable).find()).items[0].portable;
});
});
async function fillText(id, collection, dbTyp) {
const res = await wixData.query(collection)
.eq("_id", id)
.include(dbTyp)
.find();
let arr = res.items[0][dbTyp].map(e => e.title);
return arr.join(", ")
}
You can see I created a fillText() method that query the Multiple-Item references, where I map the titles to an Array and return a String with a comma between every word. Finally you can cast that String to the TextFields.
Copy the code and be sure you use the correct parameters.
@benibrodi I realise I didn’t reply yet - I didn’t use your exact code, since multiple reference categories aren’t my ideal solution (I want input through checkbox groups), but it showed me the general principle and I’ve been able to convert the tags array into text. I haven’t got the search done yet, but I think I know how I’ll manage it - thanks again!