Partager via


PortalSiteMapProvider.CreateAdditionalSiteMapNodes - Méthode

Permet l'ajout d'objets PortalSiteMapNode sous n'importe quel objet PortalWebSiteMapNode .

Espace de noms :  Microsoft.SharePoint.Publishing.Navigation
Assembly :  Microsoft.SharePoint.Publishing (dans Microsoft.SharePoint.Publishing.dll)

Syntaxe

'Déclaration
Public Overridable Function CreateAdditionalSiteMapNodes ( _
    webNode As PortalWebSiteMapNode _
) As SiteMapNodeCollection
'Utilisation
Dim instance As PortalSiteMapProvider
Dim webNode As PortalWebSiteMapNode
Dim returnValue As SiteMapNodeCollection

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

Paramètres

Valeur renvoyée

Type : System.Web.SiteMapNodeCollection
Un objet PortalSiteMapNodeCollection qui représente les nœuds à ajouter sous un nœud Web passé.

Remarques

Cette méthode est appelée après avoir rempli les objets enfants d'un objet PortalWebSiteMapNode .

En cas de substitution dans une classe dérivée, vous pouvez ajouter un objet personnalisé PortalSiteMapNode ou un objet dérivé d'un objet PortalSiteMapNode , sous le nœud de navigation Web spécifié.

Exemples

L'exemple suivant référence les assemblys suivants :

  • 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;
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Data
Imports System.Web
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Navigation
Imports Microsoft.SharePoint.Publishing
Imports Microsoft.SharePoint.Publishing.Navigation

Namespace Microsoft.SDK.SharePointServer.Samples.WebControls
    Friend Class MyPortalSiteMapProvider
        Inherits PortalSiteMapProvider
        ' Add nodes to navigation under the root node.

        Public Overrides Function CreateAdditionalSiteMapNodes(ByVal webNode As PortalWebSiteMapNode) As SiteMapNodeCollection

            ' Initialize these variables properly before running this example code.
            Dim query As SPQuery = Nothing
            Dim listName As String = Nothing



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

            If webNode Is webNode.PortalProvider.RootNode Then

                Dim additionalNodes As New SiteMapNodeCollection()

                ' Fetch a set of list items to insert.
                Dim myListItems As SiteMapNodeCollection = Me.GetCachedListItemsByQuery(webNode, listName, query, SPContext.Current.Web)
                For Each listItem As PortalListItemSiteMapNode In myListItems

                    ' Wrap these list item nodes with ProxySiteMapNodes so that they are security trimmed.
                    additionalNodes.Add(New ProxySiteMapNode(webNode, webNode, listItem))
                Next listItem
                Return additionalNodes
            End If

            Return Nothing
        End Function
    End Class
End Namespace

Voir aussi

Référence

PortalSiteMapProvider classe

PortalSiteMapProvider - Membres

Microsoft.SharePoint.Publishing.Navigation - Espace de noms

PortalSiteMapProvider