Hide duplicate cms items

Hi guys, I was wondering if anyone knew a way of hiding duplicate (in terms of a name field) items displayed in a collection list. At the moment I have created a form which allows users to submit locations, but now multiple duplicates of the locations can be submitted.

Any ideas?


Here is my public share link: LINK
(how to access public share link)

2 Likes

Hello. I have the same issue. I’m interested if you ever managed to find a solution?

1 Like

I have the same issue, how can we filter duplicate items in the dynamic list? I am using @Finsweet custom code.

1 Like

Hey All

You can use this snippet if the duplicates are based on text. Replace “.filter-component” with your own class that you wish to loop through.

document.addEventListener("DOMContentLoaded", function dumpDups() {
  const rr = new Set();
  for (const div of document.querySelectorAll(".filter-component")) {
    if (rr.has(div.textContent.trim())) {
      div.parentNode.removeChild(div);
    }
    rr.add(div.textContent.trim());
  }

  dumpDups();
});

Hope this helps ya’ll!

~ Rhino

2 Likes

Hey @RhinoReign. Thanks so much for this script. It works really well on text elements. Is there any way it can be altered to find duplicates in a list of checkboxes?

1 Like

Did you find the solution when you want to hide checkboxes that are duplicates? The current problem I’m having now is that the duplicates are gone but only the text and not the checkboxfields.

can someone please update the script so that we can apply it to checkbox labels. @RhinoReign

Hi @Sergio_Maldonado

Please can you share a Read-Only Link to your website. I’ll have a look at it a bit later today & get back to you. :wink:

~ Rhino

Hi @Yascha_Torfs99

Please share Read-Only Link to your website. Will look into it.

~ Rhino