CMS Filter Search

Hi everyone,

I hope you all had a great weekend. I have a question: Is there a straightforward method to type non-accented words into the CMS filter search bar and still have items with accented/marcon words appear in the results?

For instance, if a user types “Maori” but the item in the CMS is listed as “Māori,” currently nothing shows up. This is just one example, as several different accented letters could pose similar results.

I hope this makes sense.

Cheers!

I solved it. :grinning: I duplicated the text block with accents/macrons in the CMS item. Then, I used the below code to replicate the text without the accents or macrons, making it searchable.

<script>
document.addEventListener('DOMContentLoaded', function() {
  // Function to normalize text
  function normalizeText(text) {
    return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
  }

  // Find all elements with the 'iwi-text' field
  var iwiTextElements = document.querySelectorAll('[fs-cmsfilter-field="iwi"]');

  // Loop through each element and normalize its text
  iwiTextElements.forEach(function(element) {
    // Normalize the text
    var normalizedText = normalizeText(element.textContent);

      var resultElement = element.nextElementSibling; 
    if (resultElement && resultElement.getAttribute('fs-cmsfilter-field') === 'iwi') {
      resultElement.textContent = normalizedText;
    }
  });
});
</script>

1 Like

Great to hear you solved this Marko!

This will no longer be a limitation for Filter v2 :wink: