Retreiving a PageName but in a specified language

Vote:
 
Hello There, I am trying to retreive the pageDisplayName but only in English. I am trying to create DIVs that have the ID set to the page name in English. The code below gives me the name of the page in the navigating language. I tried using the EPiServer.Core.LanguageContext.Current.ChangeLanguageSelection to do so but it doesn't work. Help? private String CreateDiv(PageData pageObject) { EPiServer.Core.LanguageContext.Current.ChangeLanguageSelection("EN",true); // Is this the way to change the language? String pageDisplayName; if (pageObject.PageLink == Configuration.StartPage && StartPageName.Length > 0) pageDisplayName = StartPageName; else pageDisplayName = Abbreviated(pageObject.PageName); return pageDisplayName; } Thank you. Regards, Victor
#13117
Jul 13, 2007 13:29
Vote:
 
Hi Victor. What I believe you want to achieve can be done this way by using the GetPage method: PageData langPage = Global.EPDataFactory.GetPage(pageObject.PageLink, new LanguageSelector("EN")); String pagename = langPage.PageName; If you do it this way, it smart to put the GetPage in a try/catch, to prevent a possible LanguageNotFoundException to be thrown if the page does not exist in the requested language. Regards, -Geir Allan Hove
#15442
Jul 16, 2007 0:51
Vote:
 
Thanks so much. Our support people also recommended the following: This is the way to get the page in a specific language. You have to make sure the page exists in English or the language you are trying to retrieve. LanguageSelector selector = new LanguageSelector("EN"); PageData thePage = EPiServer.Global.EPDataFactory.GetPage(pageObject.PageLink, selector );
#15443
Jul 17, 2007 9:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.