Share via


PublishingWeb.IncludeInNavigation Method

Explicitly includes a subsite or a page in navigation.

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

Syntax

'Declaration
Public Sub IncludeInNavigation ( _
    useGlobal As Boolean, _
    item As Guid _
)
'Usage
Dim instance As PublishingWeb
Dim useGlobal As Boolean
Dim item As Guid

instance.IncludeInNavigation(useGlobal, _
    item)
public void IncludeInNavigation(
    bool useGlobal,
    Guid item
)

Parameters

  • useGlobal
    Type: System.Boolean
    Boolean value that controls whether Global or Current navigation is affected. Set to True to exclude the item from Global Navigation. Set to False to exclude from Current Navigation.
  • item
    Type: System.Guid
    The GUID that represents the ID of the item to include.

Remarks

When showing one or more items at once that have been hidden, using this method to show children of this Web site is faster than using the "IncludeIn…" properties on the child items.

Examples

Set the following references before using the sample code:

  • System.dll

  • System.Data.dll

  • System.Xml.dll

  • System.Web.dll

  • System.Configuration.dll

  • Microsoft.SharePoint.dll

  • Microsoft.SharePoint.Library.dll

  • Microsoft.SharePoint.Publishing.dll

[c#]

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;

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

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

namespace Microsoft.SDK.SharePointServer.Samples
{
    class IncludeInNavigationSample
    {
        // Show all pages of a specified site in global navigation.
        // Note: this only applies if some or all of these pages have
        // already been hidden from navigation.
        public static void ShowPagesInGlobalNavigation(PublishingWeb publishingWeb)
        {
            // Fetch the pages of the passed-in site.
            PublishingPageCollection pages = publishingWeb.GetPublishingPages();

            // Include each page in global navigation
            // (useGlobal = true).
            foreach (PublishingPage page in pages)
            {
                // Note: you can use page.IncludeInGlobalNavigation = 
                // true, but it reopens and updates the parent site for
                // each page. When showing multiple pages, this method
                // performs better.
                publishingWeb.IncludeInNavigation(true, page.ListItem.UniqueId);
            }

            // Save changes.
            publishingWeb.Update();
        }
    }
}

See Also

Reference

PublishingWeb Class

PublishingWeb Members

Microsoft.SharePoint.Publishing Namespace

IncludeInGlobalNavigation

IncludeInCurrentNavigation

IncludeInGlobalNavigation

IncludeInCurrentNavigation

PortalSiteMapProvider

NavigationType