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) .Select(contentRepository.Get<IContent>) .ToList();
I'm not sure about EPiServer 7, it's a bit old. Maybe something like this?
var descendants = EPiServer.DataFactory.Instance.GetDescendents(ContentReference.StartPage) .Select(EPiServer.DataFactory.Instance.Get<PageData>) .ToList();
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
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.