Try our conversational search powered by Generative AI!

Search for page implementing interface?


Is it possible to search for all pages in EPiServer implementing an interface? Without EPiServer Find?

Sep 30, 2013 15:34
private void FindAllPages(List<ContentReference> list, ContentReference parentPage)
    var loader = ServiceLocator.Current.GetInstance<IContentLoader>();
    var children = loader.GetChildren<PageData>(parentPage);

    children.ForEach(pg =>
                         if (pg is ISampleInterface)

                         FindAllPages(list, pg.ContentLink);



var list = new List<ContentReference>();
FindAllPages(list, ContentReference.StartPage);


Sep 30, 2013 21:50

An alternative soultion could be to first iterate over all ContentTypes returned from IContentTypeRepository.List and get those contentTypes where ModelType is assignable to the interface.

Then for each ot the content types found above call IContentModelUsage.ListContentOfContentType

Note that both my suggestion and Valdis suggestion (which also have the consequence that it will load up all pages to the cache) might take a considerable time to execute (especially for large sites). So if it is acceptable for the customer you should consider caching the result and then perhaps have a background timer or scheduled job that periodically updates the cached result.

Oct 04, 2013 9:26

Valdis recursive search works, but it does take some time to execute, guess I'll have to cache it :)


Oct 09, 2013 9:51

Nobody said it will come at no cost :)

Oct 09, 2013 10:03
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.