How to retrieve page information in any language

Posted by Community Admin on 04-Aug-2018 12:31

How to retrieve page information in any language

All Replies

Posted by Community Admin on 17-Nov-2011 00:00

Hello, 

To define urls for some actions, I retrieve the url using the page node id with this method: 

SiteMapNode node = siteMap.FindSiteMapNodeFromKey(pageId);

The website is multilingual, so I'm wondering how to get the french page id from the english one. All my pages are translated using split mode. 

Thanks for your help. 

Jocelyn

Posted by Community Admin on 22-Nov-2011 00:00

Hi Jocelyn Payneau,

You could use the following code:

var language = new CultureInfo("es");
var manager = PageManager.GetManager();
var englishPage = manager.GetPageNodes().Where(p => p.UrlName == "english-page").FirstOrDefault();
PageNode spanishPage;
foreach (var p in englishPage.Page.PageLanguageLink.LanguageLinks)
    if (p.UiCulture == language.Name)
    
        spanishPage = p.NavigationNode;
        break;
    

We have a helper method for this but it's currently marked as internal and we'll make it public in the next release.

Greetings,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 18-May-2015 00:00

How would the code snippet change with the API changes in version 7.0?

 

I am wanting to return a list of the page data for all the languages from the English node.  I was doing this in version 5.4 by the following code:

List<PageData> localizedPages = node.Page.PageLanguageLink.LanguageLinks.ToList();

Posted by Community Admin on 21-May-2015 00:00

Hi Jared,

Can you please try to use the sample code below in order to get the page data for the current ui culture or a specific culture:

PageManager pageManager = PageManager.GetManager();
PageNode node = pageManager.GetPageNodes().Where(n => n.Title == "YourPageTitle").FirstOrDefault();
  
var pageData = node.GetPageData(System.Threading.Thread.CurrentThread.CurrentUICulture);


Regards,
Sabrie Nedzhip
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed