NavigationTermSet.GetWithNewView method
Returns a new view of a NavigationTermSet object.
Namespace: Microsoft.SharePoint.Client.Publishing.Navigation
Assembly: Microsoft.SharePoint.Client.Publishing (in Microsoft.SharePoint.Client.Publishing.dll)
Syntax
'Declaration
Public Overridable 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 virtual NavigationTermSet GetWithNewView(
NavigationTermSetView newView
)
Parameters
newView
Type: Microsoft.SharePoint.Client.Publishing.Navigation.NavigationTermSetViewThe NavigationTermSetView object to apply to the NavigationTermSet object.
Return value
Type: Microsoft.SharePoint.Client.Publishing.Navigation.NavigationTermSet
The NavigationTermSet object.
Remarks
Use this method to manipulate the trimming settings, such as the ExcludeTermsByPermissions() 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);
}