Site Navigation Settings
If you want to set Site Navigation Settings using API here is code :)
Use this to specify the navigation items that you want to display in the navigation link bars of this site. Items in sublevels and flyouts can be modified only in the navigation of the subsite that contains these items.
This code helps you to set
- Subsites and Pages
- Sorting
- Global Navigation
- Current Navigation
private AutomaticSortingMethod GetAutomaticSortingMethodFromUI()
{
return (AutomaticSortingMethod) Enum.Parse(typeof(AutomaticSortingMethod), this.automaticSortingMethodDropDown.SelectedValue);
}
private OrderingMethod GetOrderingMethodFromUI()
{
if (this.automaticSortingRadioButton.Checked)
{
return OrderingMethod.Automatic;
}
if (this.automaticPageSortingCheckBox.Checked)
{
return OrderingMethod.ManualWithAutomaticPageSorting;
}
return OrderingMethod.Manual;
}
public SetDisplaySettings()
{
SPContext context = SPContext.GetContext(HttpContext.Current);
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(context.Site.OpenWeb(context.Web.ServerRelativeUrl));
publishingWeb.IncludeSubSitesInNavigation = this.showSubSitesCheckBox.Checked;
publishingWeb.IncludePagesInNavigation = this.showPagesCheckBox.Checked;
publishingWeb.NavigationOrderingMethod = this.GetOrderingMethodFromUI();
if (publishingWeb.NavigationOrderingMethod != OrderingMethod.Manual)
{
publishingWeb.NavigationAutomaticSortingMethod = this.GetAutomaticSortingMethodFromUI();
publishingWeb.NavigationSortAscending = this.ascendingRadioButton.Checked;
}
publishingWeb.InheritGlobalNavigation = this.inheritTopNavRadioButton.Checked;
publishingWeb.InheritCurrentNavigation = this.inheritLeftNavRadioButton.Checked;
publishingWeb.NavigationShowSiblings = this.showSiblingsLeftNavRadioButton.Checked;
publishingWeb.Web.Update();
}
Enjoy code!
Comments
Anonymous
June 01, 2008
Hi! Do you have any idea, how to set the order of the websites/pages when you set the sorting to manual? I have not been able to find a way to do this in a publishing site, since the SPNavigationNode.Move()-methods don't seem to work. Any help would be great! Cheers ChristophAnonymous
June 04, 2008
Did you call web.update() ? Any way here are good links for the same http://stsadm.blogspot.com/2007/08/site-navigation-settings.html http://blogs.msdn.com/sridhara/archive/2008/05/24/digging-into-why-sharepoint-navigation-apis-wouldn-t-work-on-sites-using-collaboration-or-publishing-site-definition.aspx http://blogs.msdn.com/sridhara/archive/2008/06/03/case-about-sorting-the-quick-launch-navigation.aspx