More in this section

Forums / Developing with Sitefinity / What is the fastest way to determine if a page exist in a particular language?

What is the fastest way to determine if a page exist in a particular language?

2 posts, 0 answered
  1. Michael
    Michael avatar
    15 posts
    11 Jul 2005
    05 Aug 2008
    Link to this post
    I know the page URL and the language. Currently, I am looping through a collection of CmsPage objects (foreach) and comparing its Name property. When I find a match, I have code like:
    if (cmsPage.LanguageVersions.ContainsKey(lcid))
        // found

    This code is too slow.

    I need something like:
    CmsManager.GetPageByUrl("~/folder1/subfolder1/page1", lcid); // or change the CurrentUICulture before calling the method without passing the LCID.

  2. Ivan
    Ivan avatar
    478 posts
    16 Jun 2015
    11 Aug 2008
    Link to this post
    Hi Michael Chan Fong,

    You can use the following sample to get all pages for particular culture (language):

    protected void Page_Load(object sender, EventArgs e)  
        Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de");  
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-de");  
    private void WritePageNames(SiteMapNode node)  
        foreach (SiteMapNode childNode in node.ChildNodes)  
           Response.Write("<br />");  

    Namely, all Sitefinity pages can be accessed through standard ASP.NET sitemap and since sitemap is a static collection it is by far the fastest and most performant way of accessing pages. Additional tip: If you need to access the actual CmsPage you can cast SiteMapNode to CmsSiteMapNode which has CmsPage property and will give you access to Sitefinity ICmsPage type of object.

    I hope you'll find this information helpful. Let us know if there is anything else we can do for you.

    All the best,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered