Question

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;
    }
Was it helpful?

Solution

I believe you need the CurrentPage.PageLink property:

PageReference listRoot = CurrentPage.PageLink;

OTHER TIPS

private IEnumerable getChildren(EducationPage CurrentPage)

It's not wise to name something own CurrentPage since many EPi classes exposes that property (unless you actually want to override it).

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

You don't need the OfType-part and as stated by Andreas listRoot should be a PageReference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top