C# code for configuring “Navigation Editing and Sorting”


Here’s some code for doing what the title states. It deletes whatever is there, then adds a couple of global and current navigation nodes respectively.

string siteUrl = "http://server/sites/blank/default.aspx";
using (SPSite site = new SPSite(siteUrl))
    PublishingWeb pw = PublishingWeb.GetPublishingWeb(site.RootWeb);
    int count = pw.Navigation.GlobalNavigationNodes.Count;
    for (int i = 0; i < count ; i++)
    SPNavigationNode prev;
    prev = pw.Navigation.GlobalNavigationNodes.AddAsFirst(new SPNavigationNode("Mi Sitio", siteUrl));
    pw.Navigation.GlobalNavigationNodes.Add(new SPNavigationNode("Mi Perfil", siteUrl), prev);
    count = pw.Navigation.CurrentNavigationNodes.Count;
    for (int i = 0; i < count; i++)
    prev = pw.Navigation.CurrentNavigationNodes.AddAsFirst(new SPNavigationNode("Información", siteUrl));
    pw.Navigation.CurrentNavigationNodes.Add(new SPNavigationNode("Sobre Mí", siteUrl), prev);

This translates into this in the UI:


Comments (0)

Skip to main content