How to get pages in current language?
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();
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.
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);