• Resolved helloimrob

    (@helloimrob)


    Hi there!
    I’m installing the polylang plugin for a friend right now, but the dropdown functionality isn’t working for me :/
    If I use it without dropdown its working, but he wants to use ~5 languages, so one below the other isn’t working.

    I’m using the following line in the header:
    <?php pll_the_languages(array('hide_current'=>1,'dropdown'=>1)); ?>

    See here:
    http://shoutkey.com/pliable

    If would really appreciate some help 🙂

    Thanks,
    Robert

    http://ww.wp.xz.cn/plugins/polylang/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Chouby

    (@chouby)

    Thread Starter helloimrob

    (@helloimrob)

    Hi!
    Thanks for the fast answer and link, didnt read that before.

    Could you tell me/us which code I have to use to get the dropdown working? Or is this too complicated?
    Im new with PHP, so I just included everything regarding your in-code comments:

    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;

    but this (maybe obviously) didn’t worked.

    Thanks!

    Plugin Author Chouby

    (@chouby)

    Try adding the line:

    global $polylang;

    above your code.

    Thread Starter helloimrob

    (@helloimrob)

    Hi! Thanks a lot for the fast answer. Added the code. Now no error anymore, but it still doesnt work :/

    see http://shoutkey.com/sanctuary

    Plugin Author Chouby

    (@chouby)

    You should output your javascript code after the language switcher, not before.

    Thread Starter helloimrob

    (@helloimrob)

    thanks a lot Chouby :)!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Dropdown doesnt work’ is closed to new replies.