다음을 통해 공유


PortalNavigation Class

Represents navigation for portal pages and other portal navigation objects.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Publishing.Navigation.PortalNavigation

Namespace:  Microsoft.SharePoint.Publishing.Navigation
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Syntax

'Declaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class PortalNavigation
'Usage
Dim instance As PortalNavigation
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class PortalNavigation

Remarks

The following code example configures portal navigation for a specified site.

Examples

/ Assemblies that need to be referenced in this sample:
//     Microsoft.SharePoint.dll
//     Microsoft.SharePoint.Publishing.dll

using System;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.Publishing.Navigation;

namespace Microsoft.SDK.SharePointServer.Samples
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // Configure the portal navigation settings for a particular site.
            using (SPSite siteCollection = new SPSite("http://yourServer"))
            {
                using (SPWeb site = siteCollection.OpenWeb("/site1"))
                {
                    PublishingWeb pubSite = PublishingWeb.GetPublishingWeb(site);
                    PortalNavigation portalNav = pubSite.Navigation;

                    // Show pages in the current navigation (on the left for LTR languages using SharePoint's
                    // default Master Pages).
                    portalNav.CurrentIncludePages = true;

                    // Increase the number of dynamic children in the current navigation to 50.
                    portalNav.CurrentDynamicChildLimit = 50;

                    // Disable global navigation inheritance, establishing the site as the new global navigation root
                    // for any sites below it; also disable the sibling display behavior for the current navigation.
                    portalNav.InheritGlobal = false;
                    portalNav.ShowSiblings = false;

                    // Enable automatic sorting for all of the site's navigation items.
                    portalNav.OrderingMethod = OrderingMethod.Automatic;

                    using (SPWeb siteToHide = siteCollection.OpenWeb("/site1/site2"))
                    {
                        // Hide a specific sub-site from display in global navigation.
                        portalNav.ExcludeFromNavigation(true, siteToHide.ID);

                        // Hide a specific sub-site from display in current navigation.
                        portalNav.ExcludeFromNavigation(false, siteToHide.ID);
                    }

                    // Save the changes to the store.
                    pubSite.Update();
                }
            }
        }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

PortalNavigation Members

Microsoft.SharePoint.Publishing.Navigation Namespace