NavigationTermSetView class

Represents contextual information that affects the calculation of certain properties for the NavigationTerm objects in a NavigationTermSet object.

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Publishing.FreezableObject
    Microsoft.SharePoint.Publishing.Navigation.NavigationTermSetView

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

Syntax

'Declaration
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public NotInheritable Class NavigationTermSetView _
    Inherits FreezableObject
'Usage
Dim instance As NavigationTermSetView
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public sealed class NavigationTermSetView : FreezableObject

Remarks

The SPWeb object, site map provider, and policy for trimming child nodes are all examples of contextual information that the NavigationTermSetView object can hold.

The NavigationTermSetView class represents contextual information that is used when rendering a navigation term set, but which is not stored in the TermStore or cached by the taxonomy navigation cache. Therefore, the NavigationTermSetView class is not considered to be part of the term set. Nonetheless, this contextual information affects the behavior of NavigationTerm object and NavigationTermSet object, similar to how a physical object's appearance may change when viewed from different angles.

The View property is a member of both the NavigationTermSet class and NavigationTerm class, and is carried along while traversing the hierarchy. For example, after calling the GetWithNewView method, the returned object will have the view, and so will any other objects obtained from members such as the Parent property and TermSet property.

The View property is read-only and fixed for a specified object instance. Therefore, the view-changing operations always return a new instance of the NavigationTerm object or NavigationTermSet object. Returning the NavigationTerm object or the NavigationTermSet object facilitates internal performance optimizations that require immutable objects.

It is possible for an SPWeb object to be configured to inherit its navigation term set from the parent SPWeb (specified by using the InheritFromParentWeb value). In this situation, the NavigationTermSetView object of the parent SPWeb object is also used for the child SPWeb object. In other words, the WebId property reflects the SPWeb object where the term set was configured, instead of the SPWeb object that is inheriting the navigation.

Examples

The example below constructs a new term set and enables managed navigation for an SPWeb object with /web1 as the URL.

static void ConfigureNavigation(SPWeb web)
{
     // Create the taxonomy term set.
     TaxonomySession taxonomySession = new TaxonomySession(web.Site);
     TermStore termStore = taxonomySession.DefaultSiteCollectionTermStore;
     Group group = termStore.GetSiteCollectionGroup(web.Site);
     TermSet termSet = group.CreateTermSet("Navigation Term Set");

     // Create a view of the term set as it will look after the web has
     // been configured to use it.
     NavigationTermSet navTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web,"GlobalNavigationTaxonomyProvider");

     // Set up the navigation-specific properties.
     NavigationTerm navTerm = navTermSet.CreateTerm("My Article", NavigationLinkType.FriendlyUrl);
     navTerm.TargetUrl.Value = "~site/Pages/Article.aspx";
     navTerm.ExcludeFromGlobalNavigation = true;

     // Output      //"/web1/Pages/Article.aspx?TermStoreId=...&TermSetId=...&TermId=...
     Debug.WriteLine(navTerm.GetResolvedTargetUrl(null, null));
     termStore.CommitAll();

     //Show how the term set will look when trimming is turned on.
     NavigationTermSetView newView = navTermSet.View.GetCopy();
     newView.ExcludeTermsByProvider = true;
     NavigationTermSet trimmedTermSet = navTermSet.GetWithNewView(newView);

     //Output: Terms with trimming = 0
     Debug.WriteLine("Terms with trimming = " + trimmedTermSet.Terms.Count);
     //Output: Terms without trimming = 1
     Debug.WriteLine("Terms without trimming = " + navTermSet.Terms.Count);

     // Finally, configure the web site to use the
     // term set above for its navigation
     WebNavigationSettings settings = new WebNavigationSettings(web);
     settings.GlobalNavigation.Source = StandardNavigationSource.TaxonomyProvider;
     settings.GlobalNavigation.TermStoreId = navTermSet.TermStoreId;
     settings.GlobalNavigation.TermSetId = navTermSet.Id;
settings.Update(taxonomySession);
}

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

NavigationTermSetView members

Microsoft.SharePoint.Publishing.Navigation namespace