Hello,
I managed to manually connect a dropdown to my database collection, and remove duplicates using the code below. However, I didn't manage to add a filter to it that only shows content of which the field "tags" contains the dynamic page's content field "item".
Could anyone help me out here?
Thanks!
import wixData from 'wix-data';
$w.onReady(function () { // Run a query that returns all the items in the collection wixData.query("CONTENT") // Get the max possible results from the query .limit(1000) .find() .then(results => { // Call the function that creates a list of unique titles const uniqueTitles = getUniqueTitles(results.items); // Call the function that builds the options list from the unique titles $w("#dropdown2").options = buildOptions(uniqueTitles); }); // Builds an array from the "Title" field only from each item in // the collection and then removes the duplicates function getUniqueTitles(items) { // Use the map method to create the titlesOnly object containing all the titles from the query results const titlesOnly = items.map(item => item.bovenliggende_bestemming); // Return an array with a list of unique titles return [...new Set(titlesOnly)]; } // Creates an array of objects in the form {label: "label", value: "value"} from the array of titles function buildOptions(uniqueList) { return uniqueList.map(curr => { // Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle} return {label:curr, value:curr}; }); } });