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
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.
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.
Some other additional options too -
Some other additional options too -
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.
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.