Share via


PortalSiteMapProvider.CreateAdditionalSiteMapNodes Method

Allows addition of PortalSiteMapNode object under any PortalWebSiteMapNode object.

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

Syntax

'Declaration
Public Overridable Function CreateAdditionalSiteMapNodes ( _
    webNode As PortalWebSiteMapNode _
) As SiteMapNodeCollection
'Usage
Dim instance As PortalSiteMapProvider
Dim webNode As PortalWebSiteMapNode
Dim returnValue As SiteMapNodeCollection

returnValue = instance.CreateAdditionalSiteMapNodes(webNode)
public virtual SiteMapNodeCollection CreateAdditionalSiteMapNodes(
    PortalWebSiteMapNode webNode
)

Parameters

Return Value

Type: System.Web.SiteMapNodeCollection
A PortalSiteMapNodeCollection object that represents nodes to add beneath a passed Web node.

Remarks

This method is called after populating the child objects of a PortalWebSiteMapNode object.

When overridden in a derived class, you can add a custom PortalSiteMapNode object or an object derived from a PortalSiteMapNode object under the specified Web node in navigation.

Examples

The following example references the following assemblies:

  • 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

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.WebControls
{
    class MyPortalSiteMapProvider : PortalSiteMapProvider
    {
        // Add nodes to navigation under the root node.

        public override SiteMapNodeCollection CreateAdditionalSiteMapNodes(PortalWebSiteMapNode webNode)
        {

            // Initialize these variables properly before running this example code.
            SPQuery query = null;
            string listName = null;

 

            // Only add items if this Web node is the root node.

            if (webNode == webNode.PortalProvider.RootNode)

            {
                SiteMapNodeCollection additionalNodes = new SiteMapNodeCollection();
 
                // Fetch a set of list items to insert.
                SiteMapNodeCollection myListItems = this.GetCachedListItemsByQuery(
                    webNode, listName, query, SPContext.Current.Web);
                foreach (PortalListItemSiteMapNode listItem in myListItems)
                {

                    // Wrap these list item nodes with ProxySiteMapNodes so that they are security trimmed.
                    additionalNodes.Add(new ProxySiteMapNode(webNode, webNode, listItem));
                }
                return additionalNodes;
            }

            return null;
        }
    }
}

See Also

Reference

PortalSiteMapProvider Class

PortalSiteMapProvider Members

Microsoft.SharePoint.Publishing.Navigation Namespace

PortalSiteMapProvider