Support » Plugin: Multisite Language Switcher » Group languages by continent

  • Resolved meneldil

    (@meneldil)


    Hello,

    I would like to know if it is possible to retrieve the translation url by specifying the ID of the blog?

    I would like to group the languages by continent, for example:

    <h4>North America</h4>
    <ul>
    	<li><a href="[link_us]">United States</a></li>
    	<li><a href="[link_ca]">Canada</a></li>
    </ul>
    <h4>Europe</h4>
    <ul>
    	<li><a href="[link_fr]">France</a></li>
    	<li><a href="[link_es]">Spain</a></li>
    	<li><a href="[link_uk]">United Kingdom</a></li>
    </ul>

    Thanks in advance.

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

    (@realloc)

    Hello,

    MSLS has the function get_msls_permalink(). You can pass a locale and get the link of the current page/post:

    <h4>North America</h4>
    <ul>
    	<li><a href="<?php echo get_msls_permalink( 'en_US' ); ?>">United States</a></li>
    	<li><a href="<?php echo get_msls_permalink( 'en_CA' ); ?>">Canada</a></li>
    </ul>
    <h4>Europe</h4>
    <ul>
    	<li><a href="<?php echo get_msls_permalink( 'fr_FR' ); ?>">France</a></li>
    	<li><a href="<?php echo get_msls_permalink( 'es_ES' ); ?>">Spain</a></li>
    	<li><a href="<?php echo get_msls_permalink( 'en_GB' ); ?>">United Kingdom</a></li>
    </ul
    
    meneldil

    (@meneldil)

    Wonderful!
    Thank you very much! 🙂

    meneldil

    (@meneldil)

    I called victory too quickly…
    The returned url is not the correct one.

    For example, if I am on the “en_US” site on the “About us” page:
    echo get_msls_permalink('en_US') returns the main domain:
    http://www.site.com

    echo get_msls_permalink('fr_FR') returns the url of the current page and not the page attached in administration:
    http://www.site.com/about-us instead of http://www.site.com/fr/a-propos.

    Where does the problem come from ?

    • This reply was modified 5 months ago by meneldil.
    Plugin Author Dennis Ploetner

    (@realloc)

    Are those pages tied together?

    meneldil

    (@meneldil)

    Yes, they are linked.

    meneldil

    (@meneldil)

    Can you reproduce the bug?

    Plugin Author Dennis Ploetner

    (@realloc)

    I will check this in the next 2 days…

    Hello, don’t forget me. 😀

    Plugin Author Dennis Ploetner

    (@realloc)

    I tried it a lot of times and it works just fine. I developed the functionality for something my company needed. Just look for the flag in the footer of the page and click on it. It opens a list of other flags where that function is used: https://www.drivek.es/faq/

    So your code is like this (I removed the img for simplicity)?

    <div class="country-switcher-dropdown__list__inner">
        <ul>
            <li>
                <a href="<?php echo get_msls_permalink( 'de_DE' ); ?>">" title="Deutschland">Deutschland</a>
            </li>
            <li>
                <a href="<?php echo get_msls_permalink( 'en_GB' ); ?>">" title="UK">UK</a>
            </li>
            <li>
                <a href="<?php echo get_msls_permalink( 'fr_FR' ); ?>">" title="France">France</a>
            </li>
            <li>
                <a href="<?php echo get_msls_permalink( 'it_IT' ); ?>">" title="Italia">Italia</a>
            </li>
        </ul>
    </div>
    Plugin Author Dennis Ploetner

    (@realloc)

    Yes, that’s correct.

    It doesn’t work on my side …
    What could cause this problem?
    A bad configuration of the plugin on my site maybe?

    I tested your code on 2 other sites to see if it comes from a configuration problem and it doesn’t work either. :/

    Plugin Author Dennis Ploetner

    (@realloc)

    When I asked before “Are those pages tied together?” … the FAQ-page in every country is linked to the others. In the frontend it takes then the current page and looks for the linked translations… it must work because it uses the underlying functionality from the rest of the plugin.

    The pages are well linked together in the administration.
    As proof, the the_msls() function works.

Viewing 15 replies - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.