Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    You can sort the output by description. Look at the settings of the plugin: https://github.com/lloc/Multisite-Language-Switcher/wiki/Settings

    It is also possible to sort the output with a filter-function. Would this be more interesting for you?

    Thread Starter nicoeve

    (@nicoeve)

    The filter solution interested me! ??
    Because the description is displayed on the front-end.

    Thanks !

    Plugin Author Dennis Ploetner

    (@realloc)

    OK. As you know you can sort by description. A solution would be that you simply use numbers before the description for having the order you like. For example:

    1 english
    2 deutsch

    Then you can go to create a filter to hide these numbers from the output:

    function my_msls_output_get( $url, $link, $current ) {
        return sprintf(
            '<a href="%s" title="%s"%s>%s</a>',
            $url,
            substr( $link->txt, 2),
            ( $current ? ' class="current"' : '' ),
            $link
        );
    }
    add_filter( 'msls_output_get', 'my_msls_output_get', 10, 3 );
    Thread Starter nicoeve

    (@nicoeve)

    Thank you! It works.

    Suggestion: It would be nice, in a future update, to add functionality where you could drag and drop the different languages ??to its own order. ??

    Plugin Author Dennis Ploetner

    (@realloc)

    Yeah, there is still a lot to do. ??

    Thread Starter nicoeve

    (@nicoeve)

    I think so. ??

    Thread Starter nicoeve

    (@nicoeve)

    Additional question:
    Is it possible to make the same filter on the description? (for substr)

    Plugin Author Dennis Ploetner

    (@realloc)

    $link is an object so this is not possibile in an easy way.

    Thread Starter nicoeve

    (@nicoeve)

    The hard way do not scare me! ??

    Plugin Author Dennis Ploetner

    (@realloc)

    This is not what I meant. It makes no sence to do it that way and the result would be equal. ?? Maybe if you can describe a little bit more what you want to do…

    Thread Starter nicoeve

    (@nicoeve)

    At first I did not want to display the description (only the flag).
    But now, yes (flag + description).

    So I have:
    “1 Fran?ais”
    “2 English”
    “3 Deutsch”

    I want to delete the number (in the front-end) that I use to choose the order of the country.

    Plugin Author Dennis Ploetner

    (@realloc)

    Thread Starter nicoeve

    (@nicoeve)

    To test MslsOutput, I tried this :

    <?php
    $display = 0;
    $exists  = false;
    $obj     = new MslsOutput();
    
    foreach ( $obj->get( $display, $exists ) as $link ) {
    	echo $link->description;
    }
    ?>

    But it does not work. ??
    This is because the object is in a “protected” mode.

    Plugin Author Dennis Ploetner

    (@realloc)

    You should print out the object to “test” it as in my example. You can create your own link object by extending MslsLink and returning an object of this type with a filter attached to msls_link_create.

    But this is a complete other story … please open a new thread for that.

    BTW MslsLink has just one property: $format_string but a method called get_description.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Order of flags/description’ is closed to new replies.