Search code examples
c#episerver

EPiServer 7 GetChildren for a specific page. and list all under that page


I'm having problems with EPiServer 7 trying to list childrens to a pagetype.

What I want is to get a page reference for the current page. I tried using PageReference listRoot = CurrentPage but it does not work.

My code looks like this:

    private IEnumerable<PageData> getChildren(EducationPage CurrentPage)
    {
        IEnumerable<PageData> pages = new List<PageData>(); 
        PageReference listRoot = CurrentPage;

        pages = contentLoader.GetChildren<PageData>(listRoot).OfType<PageData>();

        return pages;
    }

Solution

  • I believe you need the CurrentPage.PageLink property:

    PageReference listRoot = CurrentPage.PageLink;