Remove highlight class from messages.search_snippet
Hello all,
We have a custom homepage component built that is showing a few latest threads from our Announcement board. Simple stuff.
The problem is that the 'search_snippet' is highlighting the text if it's the same as the search query. In our case, the Announcement board is called 'news' and if it finds a word 'news' inside the 'search_snippet', it will be highlighted with the 'lia-search-match-lithium' class.
For now, I'm considering removing it manually with the
$('.lia-search-match-lithium').removeClass();
As far as I saw, the 'search_snippet' will always return highlighted text. Is there any way around this?
Thank you!
The "search_snippet" is doing exactly what it is intended to do. So usually don't recommend using that field for that reason (unless to display search results).
Otherwise... options include:
- Use messages.body instead; then trim HTML with utils.owasp freemarker context object, then trim to X number of characters.
- Taking the HTML of messages.search_snippet and doing a ?replace("lia-search-match-lithium","") on the string