2
votes

Does anyone know how to programmatically move/order the pages and subsites that appear in the Current Navigation when you have the Include subsites and include pages options ticked/enabled?

Background

I have written a class (in c#) which imports content into a new SharePoint site. The newly created subsites and pages all show on the Current Navigation menu as expected, but in the order they were created (I assume). I need to manually sort the pages on the menu so that they appear in the same order as the existing non-SharePoint site.

Issue

The PublishingWeb.Navigation.CurrentNavigationNodes collection does not contain any SPNavigationNode items for the pages and subsites that are automatically displayed on the Current Navigation menu, so I can't use this collection.

I know that to hide a particular page from the menu, you have to update a web property as follows:

web.AllProperties["__CurrentNavigationExcludes"] += page.UniqueId.ToString() + ";";
web.Update();

Is there something similar I can use to order the pages?

2

2 Answers