Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The following examples demonstrate how to access and manipulate Navigation settings via CSOM
namespace Publishing.Navigation.Client.Samples
{
class PortalNavigation
{
/// <summary>
/// Print Navigation settings
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static void PrintNavigationSettings(string url)
{
using (var clientContext = new ClientContext(url))
{
var navigation = new ClientPortalNavigation(clientContext.Web);
Console.WriteLine("CurrentIncludePages: {0}", navigation.CurrentIncludePages);
Console.WriteLine("GlobalIncludePages: {0}", navigation.GlobalIncludePages);
Console.WriteLine("OrderingMethod: {0}", navigation.OrderingMethod);
Console.WriteLine("AutomaticSortingMethod: {0}", navigation.AutomaticSortingMethod);
Console.WriteLine("SortAscending: {0}", navigation.SortAscending);
Console.WriteLine("GlobalIncludeSubSites: {0}", navigation.GlobalIncludeSubSites);
Console.WriteLine("CurrentIncludeSubSites: {0}", navigation.CurrentIncludeSubSites);
}
}
/// <summary>
/// Update Navigation settings
/// </summary>
/// <param name="url"></param>
public static void UpdateNavigationSettings(string url)
{
using (var clientContext = new ClientContext(url))
{
var navigation = new ClientPortalNavigation(clientContext.Web);
navigation.CurrentIncludePages = true;
navigation.GlobalIncludePages = false;
navigation.SaveChanges();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment