NavigationTermSet.GetWithNewView method

Returns a new view of a NavigationTermSet object.

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

Syntax

'Declaration
Public MustOverride Function GetWithNewView ( _
    newView As NavigationTermSetView _
) As NavigationTermSet
'Usage
Dim instance As NavigationTermSet
Dim newView As NavigationTermSetView
Dim returnValue As NavigationTermSet

returnValue = instance.GetWithNewView(newView)
public abstract NavigationTermSet GetWithNewView(
    NavigationTermSetView newView
)

Parameters

Return value

Type: Microsoft.SharePoint.Publishing.Navigation.NavigationTermSet

Remarks

Use this method to manipulate the trimming settings, such as the ExcludeTermByPermissions() method or the ExcludeTermsByProvider() method.

For example, consider a navigation hierarchy that contains three items with the titles “Published Page”, “Unpublished Page”, and “Current Only”. Only the first term appears in the navigation menu. The “Unpublished Page” item is hidden because it is a friendly URL for a publishing page that has not been published yet, and the role of the current user does not have permissions to read that type of document. The “Current Only” item is hidden because it is marked as NavigationTerm.ExcludeFromGlobalNavigation=false. The following example code shows how to enumerate the terms that would otherwise be hidden:

           static void Example(SPWeb web)
            {
                // Retrieve the active navigation term set from the Taxonomy Navigation Cache.
                NavigationTermSet termSet = TaxonomyNavigation.GetTermSetForWeb(web,
                    "GlobalNavigationTaxonomyProvider", includeInheritedSettings: false);
            
                // Output is one term: "Published Page".
                foreach (NavigationTerm term in termSet.Terms)
                    Debug.WriteLine(term.Title.Value);
            
                // Disable all exclusions.
                NavigationTermSetView newView = termSet.View.GetCopy();
                newView.ExcludeDeprecatedTerms = false;
                newView.ExcludeTermsByPermissions = false;
                newView.ExcludeTermsByProvider = false;
                termSet = termSet.GetWithNewView(newView);
            
                // Output is three terms: "Published Page", "Unpublished Page", "Current Only".
                foreach (NavigationTerm term in termSet.Terms)
                    Debug.WriteLine(term.Title.Value);
            }

See also

Reference

NavigationTermSet class

NavigationTermSet members

Microsoft.SharePoint.Publishing.Navigation namespace

Microsoft.SharePoint.Publishing.Navigation.NavigationTermSetView