NavigationTerm classe
Especifica o comportamento de navegação e as propriedades de um objeto de Term que é usado para orientar a navegação e URLs amigáveis para um site.
Inheritance hierarchy
System.Object
Microsoft.SharePoint.Publishing.Navigation.NavigationTermSetItem
Microsoft.SharePoint.Publishing.Navigation.NavigationTerm
Namespace: Microsoft.SharePoint.Publishing.Navigation
Assembly: Microsoft.SharePoint.Publishing (em Microsoft.SharePoint.Publishing.dll)
Sintaxe
'Declaração
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public MustInherit Class NavigationTerm _
Inherits NavigationTermSetItem
'Uso
Dim instance As NavigationTerm
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public abstract class NavigationTerm : NavigationTermSetItem
Comentários
Essa classe é semelhante à classe Term no namespace Microsoft.SharePoint.Taxonomy .
A classe NavigationTerm adiciona propriedades e operações que são específicas para navegação gerenciada. O estado adicional é armazenado na propriedade CustomPropeties() e só deve ser acessado por meio de classes no namespace Microsoft.SharePoint.Publishing.Navigation . Um objeto NavigationTerm pertence a um objeto NavigationTermSet .
Os objetos NavigationTerm e NavigationTermSet têm dois modos: um modo de "editável" e um "somente leitura". objetos NavigationTerm são armazenados no cache de navegação de taxonomia, que pode ser acessado por meio de funções na classe estática TaxonomyNavigation .
Exemplos
O exemplo a seguir demonstra a criação de um conjunto de termos de exemplo e, em seguida, configurando um site SharePoint Server para usar navegação gerenciada com o conjunto de termos de exemplo.
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
using Microsoft.SharePoint.Publishing.Navigation;
namespace NavigationDemos
{
public class Class1
{
public static readonly Guid NavTermSetId = new Guid("<GUID>");
public static readonly Guid TaggingTermSetId = new Guid("<GUID>");
//Creates the sample term set. If it exists, it will be deleted
public static NavigationTermSet RecreateSampleNavTermSet(TaxonomySession taxonomySession, SPWeb web)
{
// Use the first TermStore in the list
if (taxonomySession.TermStores.Count == 0)
throw new InvalidOperationException("The Taxonomy Service is offline or missing");
TermStore termStore = taxonomySession.TermStores[0];
// Does the TermSet already exist?
TermSet existingTermSet = termStore.GetTermSet(NavTermSetId);
if (existingTermSet != null)
{
//If the TermSet exists, delete it.
existingTermSet.Delete();
termStore.CommitAll();
}
// Create a new TermSet
Group siteCollectionGroup = termStore.GetSiteCollectionGroup(web.Site);
TermSet termSet = siteCollectionGroup.CreateTermSet("Navigation Demo", NavTermSetId);
NavigationTermSet navTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web,
StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
navTermSet.IsNavigationTermSet = true;
navTermSet.TargetUrlForChildTerms.Value = "~site/Pages/Topics/Topic.aspx";
NavigationTerm term1 = navTermSet.CreateTerm("Term 1", NavigationLinkType.SimpleLink);
term1.SimpleLinkUrl = "https://www.bing.com/";
NavigationTerm term2 = navTermSet.CreateTerm("Term 2", NavigationLinkType.FriendlyUrl);
NavigationTerm term2a = term2.CreateTerm("Term 2 A", NavigationLinkType.FriendlyUrl);
NavigationTerm term2b = term2.CreateTerm("Term 2 B", NavigationLinkType.FriendlyUrl);
NavigationTerm term3 = navTermSet.CreateTerm("Term 3", NavigationLinkType.FriendlyUrl);
termStore.CommitAll();
return navTermSet;
}
//Configures the web site to use Taxonomy navigation with the sample term set.
public static NavigationTermSet SetUpSampleNavTermSet(TaxonomySession taxonomySession, SPWeb web)
{
NavigationTermSet termSet = RecreateSampleNavTermSet(taxonomySession, web);
// Clear out any old settings
WebNavigationSettings webNavigationSettings = new WebNavigationSettings(web);
webNavigationSettings.ResetToDefaults();
webNavigationSettings.GlobalNavigation.Source = StandardNavigationSource.TaxonomyProvider;
webNavigationSettings.GlobalNavigation.TermStoreId = termSet.TermStoreId;
webNavigationSettings.GlobalNavigation.TermSetId = termSet.Id;
webNavigationSettings.CurrentNavigation.Source = StandardNavigationSource.TaxonomyProvider;
webNavigationSettings.CurrentNavigation.TermStoreId = termSet.TermStoreId;
webNavigationSettings.CurrentNavigation.TermSetId = termSet.Id;
webNavigationSettings.Update(taxonomySession);
TaxonomyNavigation.FlushSiteFromCache(web.Site);
return termSet;
}
}
}
Segurança de thread
Os membros públicos estática (Shared no Visual Basic) desse tipo são seguros para thread. Nenhum membro de instância pode ser garantido como seguro para thread.