How to retrieve page information in any language
Hello,
To define urls for some actions, I retrieve the url using the page node id with this method:
SiteMapNode node = siteMap.FindSiteMapNodeFromKey(pageId);
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
;
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();
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);