Search text in blocks/editor fields with special characters

Hi! I am building a search function for my website. I am using Kirby 3.5 rc4.

When searching text with Swedish special characters (åäö) I don’t get any results from fields which store their content in JSON format (like the new blocks field, and the old editor). I.e. ä is stored as \u00e4 so for example searching “vänster” doesn’t yield any results.

I found this thread and used the following “hack” from that thread: $encoded_query = trim(json_encode($query), '"');

That solves it but then the search doesn’t work for regular fields like textarea where special characters are stored normally (despite what’s stated in the thread). Does anyone have an idea how to solve this? Thanks.

hey censtin,

i removed that “hack” because it’s already solved in a new release of the editor plugin. here you can see the changes made in the file “field.php”

now you have to update the plugin and save all your content again to apply these changes and the content is saved correctly.

Wonderful, works perfectly! pretty: true also seems to work with the new blocks field in 3.5. Thank you kaltschnitt :slight_smile:

Would be nice to mention this in the docs!
It took me quite a while to find this solution. In the docs it just says ‘Saves pretty printed JSON in text files’. But it seems like nowhere is mentioned that this is essential to find words with special chars. The search is a very basic function and I think this should work out of the box or at least being documented in the official docs. :+1:

1 Like