I’m having trouble with
I would really like to make my own portfolio on wix and I am looking for a filter tag solution in order to filter certain projects depending on their given tag. My inspiration for my own website is the french studio Fago website: https://www.studiofago.com/
the site uses different tags in order for the potential client to filter through the online portfolio depending on what they are looking for.
I would like to use some similar tags such as:
- Illustration
- Animation
- Brands
- Graphic Design
- Personal
and finally: - All
I have been trying to solve this problem with chat gpt and it suggested me to use some code. Note: I have absolutely zero experience in coding so I have just been trying to follow a step by step guide but appear to be stuck somewhere.
the code it suggest is:
import wixData from 'wix-data';
$w.onReady(function () {
// Define your tags and matching buttons
const categories = [
{ id: "#btnAll", tag: "all" },
{ id: "#btnIllustration", tag: "illustration" },
{ id: "#btnAnimation", tag: "animation" },
{ id: "#btnBrands", tag: "brands" },
{ id: "#btnPersonal", tag: "personal" },
{ id: "#btnGraphicDesign", tag: "graphic design" }
];
const repeater = $w("#projectsRepeater");
const dataset = $w("#portfolioDataset");
// Check that buttons exist before attaching events
categories.forEach(category => {
if ($w(category.id)) {
$w(category.id).onClick(() => {
const selectedTag = category.tag;
if (selectedTag === "all") {
dataset.setFilter(wixData.filter());
} else {
dataset.setFilter(wixData.filter().hasSome("tags", [selectedTag]));
}
// Optional: add active state styling
categories.forEach(cat => $w(cat.id).removeClass("activeTag"));
$w(category.id).addClass("activeTag");
});
} else {
console.warn("Button not found:", category.id);
}
});
});
Working in
I al working in Wix Studio Editor
Site link
This is the test link.
Extra context
I have been working with buttons for the visual of the tags, each button has a name referring to what is written in the code. so for example the ID for the button Illustration is btnIllustration etc.
the tags do not seem to work as I wanted it (basically the same as the reference website). And I am wondering if I am doing something obviously wrong.
Could anyone help me ?
Thanks in advance,
Sarah H