Come importare il termine impostato con Utilizzare questo termine impostato per la proprietà di navigazione del sito selezionata utilizzando PowerShell?
-
10-12-2019 - |
Domanda
$session = Get-SPTaxonomySession -Site $sitename
$termStore = $session.TermStores[“Managed Metadata Application”]
$group = $termstore.CreateGroup(“My New Group”)
$group.Description = "My Term Group"
$termStore.CommitAll()
$termSet = $group.CreateTermSet(“My TermSet”,1033)
$termSet.Description = “My TermSet”
$termSet.IsAvailableForTagging = $true
$termSet.IsOpenForTermCreation = $true
$termStore.CommitAll()
.
Qui come $ Termset.isAvailableFortagging Voglio abilitare "Utilizzare questo termine impostato per la navigazione del sito" utilizzando PowerShell.
Grazie in anticipo
Soluzione
Finally I achieved it with following code.
$navigationSet = $group.CreateTermSet($termsetName)
$navigationSet.SetCustomProperty("_Sys_Nav_IsNavigationTermSet", "True")
$navigationSet.SetCustomProperty("_Sys_Nav_AttachedWeb_SiteId", $site.ID.ToString())
$navigationSet.SetCustomProperty("_Sys_Nav_AttachedWeb_WebId", $site.RootWeb.ID.ToString())
$navigationSet.SetCustomProperty("_Sys_Nav_AttachedWeb_OriginalUrl", $site.RootWeb.Url )
Altri suggerimenti
You do this in powershell by converting the TermSet to a NavigationTermSet
$site = Get-SPSite -Identity $sitename
$navTermSet = [Microsoft.SharePoint.Publishing.Navigation.NavigationTermSet]::GetAsResolvedByWeb($termSet, $site.RootWeb, "GlobalNavigationTaxonomyProvider");
Now you have access to the navigation term set object in powershell and can use it like in oldbam's answer
This code should help you:
// Obtain navigation term set
NavigationTermSet navigationTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web, "GlobalNavigationTaxonomyProvider");
// Specify that this term set can be used for site navigation
navigationTermSet.IsNavigationTermSet = true;
// specify target page for all terms in this term set
navigationTermSet.TargetUrlForChildTerms.Value = "~site/Pages/Topics/Topic.aspx";
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange