Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Fetch all pages of MenuTree from RootPage


with the help of below code i am able to fetch all the pages from rootpage, for eg 1.StandardPage and NewsPage

PageDataCollection children = EPiServer.DataFactory.Instance.GetChildren(PageReference.RootPage);

but consider if StandardPage had children for eg StandardPage1 i am unable to fetch that.

i think i need to use some recursive function to fetch all the pages from RootPage.

i am unable to find a solution for the same.

help appreciated

Aug 04, 2016 10:33

Hi rushabhs,

If you don't want to write a recursive function, you can call GetDescendents method.

In EPiServer 9, you could use something like this:

var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var descendants = contentRepository.GetDescendents(ContentReference.StartPage)

I'm not sure about EPiServer 7, it's a bit old. Maybe something like this? 

var descendants = EPiServer.DataFactory.Instance.GetDescendents(ContentReference.StartPage)
Aug 04, 2016 17:47

Hi  Dejan,

Thanks a lot for the help...i am getting all the pages from RootPage in var descendants..But i want to arrange the pages as per the tree structure of episerver menu tree..

i think i need to arrange the data in json format..but not sure how it can be achieved.

Could you please help me on that?

Thanks in advance

Aug 11, 2016 9:52
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.