Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Trying to set up a language switcher, using the following code which I have seen on a number of V8 blog posts
@foreach (var (culture, infos) in Model.Cultures) { <a href="@Model.GetUrl(culture)">@Model.Value("language",culture)</a> }
Problem is, it returns an Object reference not set to an instance of an object.
The cultures work as I can switch between languages on the test site I'm playing about with.
Anyone else came across this problem, or know how to fix it
Just an update to this, the following code from V7 still works OK
@{ var homePage = Umbraco.ContentAtRoot().FirstOrDefault(); string redirectToCulture = homePage.Value<IPublishedContent>("redirectToCulture",culture:"en-GB").UrlAbsolute(); foreach (var lang in Services.LocalizationService.GetAllLanguages()) { <a href="@($"{redirectToCulture}?lang={lang.IsoCode}")">@lang.CultureName</a> } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Model.Cultures returns null
Trying to set up a language switcher, using the following code which I have seen on a number of V8 blog posts
Problem is, it returns an Object reference not set to an instance of an object.
The cultures work as I can switch between languages on the test site I'm playing about with.
Anyone else came across this problem, or know how to fix it
Just an update to this, the following code from V7 still works OK
is working on a reply...