Try our conversational search powered by Generative AI!

GetPageLanguage and GetPage returning wrong language

Vote:
 

HI guy any help with this is greatly appreciated...im stumped at this point.

I have one page with two language versions (English and French) with the title being "FAQ". I changed the page title on the english side to say "FAQee" and french title is still "FAQ" saved and published...

they show up perfectly fine in the cms so now i went to collect the information and found that regardless of the current page language id GetPage and GetPageLanguage always returns the last published page version. so if french was published last...thats what i get back.

LanguageSelectorContext.SelectedLanguage shows that the alternate language does actually exist...

 

anyone know what im doing wrong?

 

thanks in advance guys!

 

 

LanguageSelector lng = new LanguageSelector(CurrentPage.LanguageID);

//try to get the page in the current language
PageData data = null;
data = DataFactory.Instance.GetPage(new PageReference(pageReference), lng);

//see if the language actually exists
LanguageSelectorContext langContext = new LanguageSelectorContext(data);
LanguageSelector.AutoDetect(false).SelectPageLanguage(langContext);

//try to change to the current language AGAIN
data = data.GetPageLanguage(CurrentPage.LanguageID);

    

 

#57579
Mar 21, 2012 16:11
Vote:
 

I think you should use .LanguageBranch instead of .LanguageID...

#57696
Mar 24, 2012 0:44
Vote:
 

didnt work. i am still getting the same results.

#57814
Mar 28, 2012 16:21
Vote:
 

PageDataCollection languagesForCurrentPage = EPiServer.DataFactory.Instance.GetLanguageBranches(CurrentPage.PageLink);

That will get you all language versions of CurrentPage...

You can loop or do whatever, sort it by date etc:

                foreach (PageData pd in languagesForCurrentPage)
                {
                    if (!CurrentPage.LanguageBranch.Equals(pd.LanguageBranch))
                    {                       
                    }
                }

#57815
Mar 28, 2012 16:29
Vote:
 

thanks... GetPageLanguageBranches did the trick...i dont understand why the other API calls did not return the correct page version...??

#57820
Mar 28, 2012 20:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.