9Oct/090
Get LinkURL in context of choosen language
Recently I had a problem with getting URL of the page in context of the language different that master one.
I had a PageDataCollection with pages:
1 2 3 4 5 6 7 8 9 | LanguageSelector language = new LanguageSelector("EN") ; foreach (PageData childPage in DataFactory.Instance.GetChildren(startPage, language)) { ... } |
In the collection I had correct pages - children of startPage that had English language version.
Then for each page I wanted to write it's URL using childPage.LinkURL Unfortunately all those pages had different master language (Norwegian) and I was receiving URLs like "/no/mypage"
After searching for the solution for a while my colleague Robert told me how to do it. The solution is:
1 2 | string LanguageBranch = "EN"; string link = UriSupport.AddLanguageSelection(childPage.LinkURL, LanguageBranch); |
Now I get URLs that looks like this one: "/en/mypage"
Thank you Robert