More in this section

Forums / General Discussions / How to get pages in current language?

How to get pages in current language?

3 posts, 0 answered
  1. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    10 May 2011
    Link to this post
    I want to get a list of pages in the current culture.

    I am using this to list ALL pages, how can I filter with the current culture?

    var pageNodes = App.WorkWith().Pages().LocatedIn(PageLocation.Frontend).Get().ToList()
        .Where(p => p.Parent != null &&
            p.Page == null &&
            p.ShowInNavigation &&
            p.AvailableCultures.Contains(curretCulture))
        .OrderBy(p => p.Ordinal)
        .SelectMany(p => p.Nodes)
        .ToList();
  2. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    10 May 2011
    Link to this post
    Actually I guess the problem is the status. It is also getting some pages without title, maybe it is getting drafts or something.

    I've added "where title is not null" on this filter, it already helps.
  3. Pavel Iliev
    Pavel Iliev avatar
    140 posts
    Registered:
    18 Jul 2016
    17 May 2011
    Link to this post
    Hi Bruno,

    Depending on what you need you can also use the sitemap:

      var rootnode = SiteMap.RootNode.RootNode;
                if (rootnode.HasChildNodes)
                {
                    var nodes = rootnode.GetAllNodes();
    
                    foreach (SiteMapNode node in nodes)
                    {                    
                        if (!string.IsNullOrEmpty(node.Title))
                        {
                            this.Page.Response.Write(node.Title);
                        }
                    }
                }
    

    Best wishes,
    Pavel
    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 posts, 0 answered