+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to retrieve page information in any language

How to retrieve page information in any language

4 posts, 0 answered
  1. jocelyn payneau
    jocelyn payneau avatar
    51 posts
    Registered:
    07 Dec 2009
    17 Nov 2011
    Link to this post
    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
  2. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    22 Nov 2011
    Link to this post
    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
  3. Jared
    Jared avatar
    122 posts
    Registered:
    04 Apr 2013
    18 May 2015
    Link to this post

    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();

  4. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    02 Dec 2016
    21 May 2015
    Link to this post
    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
     
4 posts, 0 answered