Language display in a drop-down menu, and in the header.
-
Hello,
My question is how to display in the header of my template, a drop-down menu of languages (I have 9 different languages).
I did go to this page “https://github.com/lloc/Multisite-Language-Switcher/wiki/Generate-the-output” as you indicated in this ticket “http://wordpress.org/ support / topic / flag-display-customization? replies = 2 “but I do not exactly know what code I should use? When I test with
if (function_exists (‘the_msls’)) the_msls ();
I have the choice of languages is displayed but how to display the language list in a drop-down, with the current language as the selected item?(which codes should I use?)? Thank you for your help!http://wordpress.org/extend/plugins/multisite-language-switcher/
-
OK … it’s not that hard. 😉
Insert some code – for example like this –
<select id="msls_languages"> <?php if (function_exists ('the_msls')) the_msls (); ?> <select>
in your header where you would like to have the drop-down. In your functions.php insert a function like this
function my_msls_output_get( $url, $link, $current ) { return sprintf( '<option value="%s"%s>%s</option>', $url, ( $current ? ' selected="selected"' : '' ), $link ); } add_filter( 'msls_output_get', 'my_msls_output_get', 10, 3 );
Hope this helps.
Cheers,
Dennis.Thank you for your help, the solution works very well. but I do not have flags that appear 🙁 is it possible to display ” name + flag” in this drop-down menu?
An image in an option? I’m quite sure that this will not work in all browsers.
I think you could accomplish this much easier if you would set the output-options of the plugin (please read https://github.com/lloc/Multisite-Language-Switcher/wiki/Settings) and then try to format the generated
<ul>
and the<li>
s by this line of code<?php if (function_exists ('the_msls')) the_msls (); ?>
with CSS.
Again thank you for your help! I will try to implement this solution.
However I have a problem with the drop down menu: Links do not work. I can not switch between versions. I was able to do so as I do not utlisais menu. You know why?below a link :
Thanks for the link (BTW: There are images in the generated code of the drop-down. Please have a look at the html-code!).
Yes, a drop-down like this does nothing. You could make use of a little bit of JavaScript. Maybe something like that:
http://stackoverflow.com/questions/5150363/onchange-open-url-via-select-jquery
Ok,Thank you for your availability and your help!
Hi,
Great plugin you made, really helpful. But i dont manage to get it into the topbar. Ive already copied the
<?php if (function_exists ('the_msls')) the_msls (); ?>
text in the header.php and it is now displaying but id to doesnt have any links, the links are not working.Again: thanks a lot
Do you have a link where I can see this?
- The topic ‘Language display in a drop-down menu, and in the header.’ is closed to new replies.