Search code examples
c#episerver

Get all the pages inherited from the certain page in Episerver


There is an abstract base page

public abstract class BasePage : PageData

There are some pages that are inherited from this page

public class ChildPage : BasePage
public class ChildPage2 : BasePage

I need to retrieve all the pages that are inherited from the BasePage. In PropertyCriteria I could use only ChildPage and ChildPage2 for the search by PageTypeID. So this approach would not solve the issue in my case


Solution

  • Your most viable options are to 1) retrieve all pages (with GetChildren or GetDescendants, depending on content structure) of the base type, or 2) use Find.

    Episerver Find makes this kind of thing trivial, provided your site actually uses Find. :/

    A third (not recommended) option would be to identify all of the sub-types and use multiple FindPagesWithCriteria calls, but that would be slow. FPWC is entirely uncached, and results in DB calls.

    Personally, I never use FindPagesWithCriteria for anything other than certain administrative features not dealing with rendering the actual site.