Also I think it's not necessary to set the language names on your document type. You can use the culture info or use the Umbraco localization services to retrieve the language display name.
I think it's a good idea to refactor the code a bit further, but it shows how you can achieve that the current language is always the first one in the list.
Showing active language in languagepicker
Hi guys
Doing a languagepicker for a multilingual site, and it's almost working as wanted.
My only problem, is that I would like it to show the active language as the first language.
At them moment, not matter which language layer I'm on, it always shows English first.
Any suggestions on how to achieve this?
Best,
Henrik
Try this:
The above code splits the current language from the other languages by adding a
Where()
statement to the foreach:Also I think it's not necessary to set the language names on your document type. You can use the culture info or use the Umbraco localization services to retrieve the language display name.
Thanks a bunch Corné!
It's working now, besides the flag for the current language.
You added
<img src="@Model.Url"/>
as the URL for the current language, which gets the page URL, rather than the image URL.Got any idea on how to retrieve the image URL?
Henrik
Ah, my bad!
I have edited the code example above.
I think it's a good idea to refactor the code a bit further, but it shows how you can achieve that the current language is always the first one in the list.
Perfect!
Works like a charm.
Thanks a bunch for your help :)
Have a great day
Henrik
is working on a reply...