In addition to our XML sitemap, I'm trying to create a sitemap that list all our pages inside an unordered list. The recursive function I've written (see below) works getting all the pages, but the order isn't correct despite using the OrderBy() method.
I need to output all the pages in the same order they appear in Edit mode, so my initial thought was to arrange my results based on their sort index. I went through my content tree and made sure each parent node had it's Sort subpages field set to According to sort index and adjusted all the values. Everything looks and acts correctly within the Edit view, but when I print out my results in the View file I'm not sure how it's determining it's order.
Is there something I missing?
Here's the function I wrote to get all the pages:
protected void DescendContentTree (IContent page, Hashtable tree)
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var check = contentRepository.GetChildren<PageData>(page.ContentLink)
?.Where(x => !(x.StopPublish < DateTime.Now))
?.OrderBy(x => x.SortIndex);
children = new Hashtable();
foreach (PageData item in check)
children = null;
And here's a sample of my output: (Showing the sort index value of the page)
I guess a Hashtable is not sorted. Use another collection type.