We'd like to return a list of all pages with their page types from an EPiServer 8.0 site. Preferably I'd like to do this within a navigation structure via a list of ContentAreaItem objects. But I found an example that suggests the FindAllPagesWithCriteria method. But I'm having difficulty creating the criteria object.
What we would like to see is everything that is published. Below is what I have. But it's unclear to me how to define the criteria as give us all the pages that are published.
var criteria = // What do I put here?
var queryService = ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>();
var pages = queryService.FindAllPagesWithCriteria(PageReference.StartPage, criteria, "en", new LanguageSelector("en"));
The other (preferred) alternative is this: can I get the page type from a ContentAreaItem object? I've got some navigation tree code that has an IList<ContentAreaItem> list of items. If I can get the Page Type from a ContentAreaItem, it would be even better.
Thanks for your help.
You can get the Type from an ContentAreaItem with something like (ideally you'd use constructor injection to get the IContentLoader and not the ServiceLocator):
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
foreach (ContentAreaItem item in items)
if (!contentLoader.TryGet(item.ContentLink, out content))
var type = content.GetOriginalType();
Is that what you're looking for?
Why can't you just use the built in report?
Henrik, I was unaware of a built in report. Where is that? Also, my requirements have changed. We need all of the content types, not just pages. So I'll just post a new question. Thanks.
What precisely are you trying to achieve now? It sounds like you want some kind of report that lists all content and it's content type?
As Henrik mentioned, Episerver comes with several reports out-of-the-box (http://webhelp.episerver.com/latest/cms-edit/reports.htm), but if that's what you need then none are going to fulfill that requirement.
Thank you Jake. I'll check those reports out. Appreciate your help.
Some other additional options too -
Oh, Epi 8.... maybe only the first option then, or 'downgrade' the tool