Forums › Forums › Search & Filter Pro › Filter order is wrong for Scandinavian characters
- This topic has 7 replies, 4 voices, and was last updated 2 years, 9 months ago by Anonymous.
-
Anonymous(Private) January 29, 2021 at 8:25 am #274527
I’ve created a filter based on a meta field, and set it to order by values ascending alphabetically:
But the orderby ignores Scandinavian characters. Values starting with the letter Ø should come after Z, but in the dropdown it’s grouped with the Os:
Scandinavian characters like ÆØÅ comes after Z.
Anonymous(Private) February 2, 2021 at 12:16 pm #274982It does not respect the collation, which is set to
utf8mb4_danish_ci
.I had to use a filter to fix it:
function sfp_sort_scandinavian( $input_object, $sfid ) { if ( '_sfm_employees' === $input_object['name'] ) { usort( $input_object['options'], function( $a, $b ) { return strcmp( $a->value, $b->value ); }); } return $input_object; } add_filter( 'sf_input_object_pre', 'sfp_sort_scandinavian', 10, 2 );
Ross Moderator(Private) February 3, 2021 at 6:55 pm #275259Hi there
Yeah unfortunately we’re just doing a PHP sort on the custom field – I realise we’re not doing this properly though to account for language specific characters.
I’ll make a note of this for version 3 (out in a month or so), but if it creeps back in, get in touch and I will make sure we patch the plugin.
Best
Anonymous(Private) January 20, 2022 at 10:37 am #276445HI,
I’m also having the same problem. This time with Swedish letters: ÅÄÖ.
Server connection collation is set to utf8mb4_swedish_ci within phpmyadmin but the search result still shows Z as the last letter instead of Å Ä Ö.I want to sort my result based on the names (post title) of my posts being filtered. The user has the option to filter between ascending (A-Ö) or descending (Ö-A)
What to do?
-
AuthorPosts