SharePoint Tip #24: Changing a Web Site's Navigation Settings Changing a web site's navigation settings is pretty easy using the SharePoint user interface. You just click the Site Actions button, select the Site Settings option, and click on Navigation. But how do you do it programmatically? Most navigation options on a SharePoint web site are manipulated through the SPWeb object's property bag. Set the following properties to configure a web site's navigation settings: • __IncludeSubSitesInNavigation: Set this property to True to show the subsites of the current site on the global and current navigation menus. Set it to False to hide the subsites. • __IncludePagesInNavigation: Set this property to True to show the pages on the global and current navigation menus. Set it to False to hide the pages. • __InheritCurrentNavigation: Set this property to True to display the same navigations items as the parent site in the current navigation menu. Set it to False to display only items from the current site and subsites. • __NavigationShowSiblings: Set this property to True to display the navigation items below the current site and the current site's siblings, in the current navigation menu. • __NavigationOrderingMethod: Set this property to one of the following values: o 0: Sort the navigation items automatically o 1: Sort the subsites manually but the pages automatically o 2: Sort the navigation items manually • __NavigationAutomaticSortingMethod: When using automatic ordering, set this property to one of the following values: o 0: Sort by Title o 1: Sort by Created Date o 2: Sort by Last Modified Date • __NavigationSortAscending: When using automatic ordering, set this property to True if the automatic sorting of the navigation items should be done in ascending order. Set it to False to use descending order. Note: there are two underscore characters (_) in each property name. Example In the example below, I'm setting the navigation options to: • Show only the current site's navigation items in the global navigation • Show the current site's sub sites in the global navigation • Don't show the pages in the global navigation • Show only the current site's navigation items in the current navigation • Don't show the current site's siblings in the current navigation • Sort the navigation items manually // break inheritance of global navigation web.Navigation.UseShared = false; // show subwebs but don't show pages in global navigation web.AllProperties["__IncludeSubSitesInNavigation"] = "True"; web.AllProperties["__IncludePagesInNavigation"] = "False"; // show only current site's navigation items in current navigation web.AllProperties["__InheritCurrentNavigation"] = "False"; web.AllProperties["__NavigationOrderingMethod"] = "2"; web.AllProperties["__NavigationShowSiblings"] = "False"; web.Update();
SharePoint Tip
最新推荐文章于 2025-07-17 10:01:19 发布
本文介绍如何使用SharePoint的用户界面及编程方式更改网站导航设置。包括显示子站点、页面的选项,继承父站点导航,手动排序等配置。
420

被折叠的 条评论
为什么被折叠?



