I’ve managed to get around building the bulk of this site, but my current issue is, when the “All” option is clicked, it returns with “no results found” which is not true, because with all my other filters, it all seems to be working. It’s just that “all” option that is really irritating me. Is there a way where I can either remove the “All” option or get it to correspond with my other results?
The dropdown is linked to a dataset field which consists of tags.
Hey Amanda! No, you’re not missing anything, I didn’t think to add any code re. when “all” is selected… It’s not named in the database. Any ideas on the code I should write when “all” is selected and nothing is typed?
So, I think in your dropdown change event you need an option for if the dropdown value is “All”
All will not exist in the db, it’s just the text on the button.
In the if statement, you can provide what you want to happen in the case of “All” which would be to clear the filters
From the docs:
“To clear a dataset’s current filter, call setFilter() and pass it an empty filter. You create an empty filter by calling the filter() function without chaining any of the additional filter functions mentioned above.”
I"m wondering if this isn’t a code problem at all. Are there any settings in that button that you have configured to connect to the dataset? I"m wondering if there is some clash between the code you have written and any no-code settings in the element config?
Before you started adding any code at all, what was happening?
I’m beginning to think the issue is the dropdown being linked to the dataset. I was literally pulling my hair out over the weekend re-arranging, adding, removing code, watching youtube vids, and couldn’t find a solution. I’m thinking my final solution would have to be manually linking the dropdown items to the repeater with the code, and getting that to correspond with the search bar. It’s going to be gruelling and time-consuming but it’s the most logical way.
I think it is the code, when I remove it, the dropdown filters normally, but there is no “counttext” obviously, so ideally I’d use both to filter results. I was going to start from scratch, but I’ve come this far. I’m really stuck
Just for anyone who is interested in the solution:
After a bunch of tweaking, research, youtube and screaming (lol), I found a solution.
I figured I had to manually add the dropdown items rather than link it to the dataset. In that regard, I named the dropdown items and their values were identical to the tags which I created in the dataset, and followed it up with this code.
It turns out that if you link your dataset with a field identity of tags (arraystring) any results will automatically have an “All” result if you link it to your collection and filter content and not collect content.
With this code, I was able to link my search box and dropbox values to my repeater AND have the total count show up above the repeater. Just leaving this here, for anyone else who finds themselves in this or a similar situation.