How do I retrevie all the published instances of a certain PageType non culture dependant?For the moment I use this: ServiceLocator.Current.GetInstance<IContentModelUsage>().ListContentOfContentType(contentType) but it return multiple time the reference to the same item with different versions.
I would suggest that you use PageTypeBuilder with a requirement on PageType:
var repository = ServiceLocator.Current.GetInstance<IContentTypeRepository<PageType>>();
var contentType = repository.Load(typeof(YourPageType));
var pageTypeId = contentType.ID;
var collection = new PropertyCriteriaCollection
Required = true,
Name = "PageTypeID",
Condition = CompareCondition.Equal,
Type = PropertyDataType.PageType,
Value = pageTypeId.ToString(CultureInfo.InvariantCulture)
var queryService = ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>();
pages = queryService.FindPagesWithCriteria(rootPage.PageLink, collection);
You could also run the result in the pages variable through the FilterForVisitor Filter.
This will search directly in your database so if this will be run many times under a short period of time I would suggest you add this to the cache.
I guess the fastest way is to use the FindAllPagesWithCriteria method if you don't have EPiServer Find or similar.
Hope this helps.
If I remember correctly the difference with FindAllPagesWithCriteria and FindPagesWithCriteria would be that FindAllPages does not filter out pages that the visitor cannot access. right?
But running the result through FilterForVisitor would also solve that.
Thank you very much for your quick respond it work perfectly! Exactly what I need!