Try our conversational search powered by Generative AI!

How can I return all published pages with their page types in an EPiServer 8.0 site?

Vote:
 

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.

#199505
Nov 29, 2018 0:07
Vote:
 

Hi Ken,

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)
{
    IContent content;

    if (!contentLoader.TryGet(item.ContentLink, out content))
    {
        continue;
    }

    var type = content.GetOriginalType();
}

Is that what you're looking for?

/Jake

#199507
Nov 29, 2018 1:48
Vote:
 

Why can't you just use the built in report?

#199509
Nov 29, 2018 7:51
Vote:
 

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.

#199546
Nov 29, 2018 23:00
Vote:
 

Hi Ken,

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.

#199565
Nov 30, 2018 17:11
Vote:
 

Thank you Jake. I'll check those reports out.  Appreciate your help.

#199569
Nov 30, 2018 18:50
Vote:
 

Some other additional options too -

  1. You could have a look in the Find Overview section
    • (but this will only be reliable if everything is being indexed)
  2. Check out this tool https://blog.nicolaayan.com/2018/05/episerver-cms-audit-nuget-package/ 
    • has been further extended by the great Allan Thraen more recently than this post too
#199620
Dec 03, 2018 23:38
Vote:
 

Some other additional options too -

  1. You could have a look in the Find Overview section
    • (but this will only be reliable if everything is being indexed)
  2. Check out this tool https://blog.nicolaayan.com/2018/05/episerver-cms-audit-nuget-package/ 
    • has been further extended by the great Allan Thraen more recently than this post too
#199621
Dec 03, 2018 23:38
Vote:
 

Oh, Epi 8.... maybe only the first option then, or 'downgrade' the tool

#199622
Dec 03, 2018 23:38
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.