Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Filter order is wrong for Scandinavian characters

Viewing 8 posts - 1 through 8 (of 8 total)
  • Gnist Design
    #274527

    I’ve created a filter based on a meta field, and set it to order by values ascending alphabetically:
    Meta Field Order

    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:
    Frontend dropdown

    Scandinavian characters like ÆØÅ comes after Z.

    Trevor Moderator
    #274581

    I think the sorting is dependent on the collation setting on your server SQL database, which you need to make sure is the language you want. You should be able to find this out if you have a database tool in your hosting package.

    Gnist Design
    #274982

    It 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 );
    
    Trevor Moderator
    #274988
    This reply has been marked as private.
    Ross Moderator
    #275259

    Hi 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

    Pierre Bendayan
    #276445

    HI,
    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?

    Trevor Moderator
    #276447

    Hi Pierre

    Can you raise the issue in our new Support ticket system?

    Pierre Bendayan
    #276449

    Sure. Thanks for the quick response.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.