Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Chrystl

    (@chrystl)

    Hello Wincher

    Polylang do not display dropdown with flags.
    If you want a dropdown with flags you must code it.

    Here a topic about that:

    https://www.ads-software.com/support/topic/developer-wanting-to-lock-down-polylang-for-drop-down-flags-menu?replies=2

    Have a good day

    Thread Starter Wincher

    (@wincher)

    Thanks you for your answer!
    Maybe I did not express myself well, I don’t want a dropdown with flag images but just a dropdown with html-text languages.
    I insert <?php pll_the_languages(array(‘dropdown’=>1)); ?> inside header.php. But link inside dorpdown doesn’t work.
    I rode a post about this and it was mentioned to fix a part of code inside widget-languages.php but I’m nos sure about what I have to do.

    I think it’s about this :

    function widget($args, $instance) {
    	global $polylang;
    	foreach ($polylang->get_languages_list() as $language) {
    	$url = $polylang->get_translation_url($language);
    	$urls[] = '"'.esc_js($language->slug).'":"'.esc_url($url).'"';
    	}
    
    	$urls = implode(',', $urls);
    
    		// javascript to switch the language when using a dropdown list
    		if ($dropdown) {
    			foreach ($polylang->model->get_languages_list() as $language) {
    				$url = $force_home || ($url = $polylang->links->get_translation_url($language)) == null ? $polylang->links->get_home_url($language) : $url;
    				$urls[] = '"'.esc_js($language->slug).'":"'.esc_url($url).'"';
    			}
    
    			$urls = implode(',', $urls);
    
    			$js = "
    				<script type='text/javascript'>
    					//<![CDATA[
    					var urls = {{$urls}};
    					var d = document.getElementById('lang_choice');
    					d.onchange = function() {
    						for (var i in urls) {
    							if (this.value == i)
    								location.href = urls[i];
    						}
    					}
    					//]]>
    				</script>";
    
    			echo $js;
    		}
    	}

    Could you help me?

    Plugin Support Chrystl

    (@chrystl)

    The function <?php pll_the_languages(array('dropdown'=>1)); ?> do not call js.

    But someone worked on it and:
    https://www.ads-software.com/support/topic/help-with-drop-down-action?replies=3

    Thread Starter Wincher

    (@wincher)

    You’re incredible !
    Thanks you so much

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Dropdown flag’ is closed to new replies.