How to implement a Langauge Switcher considering S...
# help-with-umbraco
u
Hey im having a small problem. Whats the "best" way of implementing a language switcher. My problem is that im using surfacecontroller where a return views from my views folder. But when i do that the returned View dont have access to IPublishedContent.Model (obviously). Without having access to Model. I cant use Model.Url(), or Model.Cultures etc. Would be very much grateful for any kind of help.
r
Here isa bit of information on models and controllers by the excellent mind and writing of @marcemarc https://our.umbraco.com/forum/umbraco-9/107763-surfacecontroller-its-view-and-their-model as a simple exmaple you could post a querystring back to the page a bit like this :
Copy code
[HttpPost]
 public IActionResult Submit(Model formCollection)
 {
     var queryString = new QueryString("?job=" + formCollection.JobId);

if (querystring == 1){

    return           RedirectToUmbracoPage(new Guid(somevaluToString()), queryString);
}
else{

                //do something else
          }
}
that's obviously pseudo code but its just to gove you an idea
k
Not using surface controllers for this would save you a lot of trouble. If you use different hostnames or paths instead, everything works out of the box. Why do you have to use surface controllers?
r
We added variant URLs in a link to the language selector list. I am not sure whether this is a good solution. We were using Surface controller that redirects to language variant pageurl (302). This was causing issues in Google search index. So we changed from surface controller to simple links.
2 Views