PnP provisioning Search Setting Verticals

Highlighted
New Contributor

I manually added some custom verticals in my O365 Search Settings (in the Search Center). That's working fine in the corresponding Navigation Web Part.

 

But now I have to provision this verticals with PnP (in a xml template). How can I do that?

5 Replies
Highlighted

Hi @T. de Groot,

 

Do you mean  the Search Navigation options?

 

SearchNav.PNG

So rather than Everything, People, Coversations and Videos you have custom links here?

 

 

That's exactly the situation. But how I can configure this with a PnP xml template is rocket science for me.

Highlighted

Interesting question. I had a look through the templates even when I included the search configuration with 

Get-PnPProvisioningTemplate -Out search.xml -IncludeSearchConfiguration 

These options aren't exported. It might be worth it to report this as an issue on the github site.

 

https://github.com/SharePoint/PnP-Sites-Core

 

 

Highlighted

SearchNavigation is not in the schema at the moment.

In the next hour, i will create a Powershell CSOM script to do it. When it works, i will contribute to Git.

Highlighted

I Created my solution in Powershell CSOM. Now I have to recreate it for the PnP Scheme. It creates 5 custom verticals.

 

 

$node1Title ="Intranet"

$node2Title ="News"

$node3Title ="Documents"

$node4Title ="People"

$node5Title ="Everything"

 

$node1Url ="/sites/GI/En/search/Pages/results.aspx"

$node2Url ="/sites/GI/En/search/Pages/newsresults.aspx"

$node3Url ="/sites/GI/En/search/Pages/documentsresults.aspx"

$node4Url ="https://xxx.sharepoint.com/search/Paginas/peopleresults.aspx"

$node5Url ="https://xxx.sharepoint.com/search/Paginas/results.aspx"

 

$addNodes = $true

 

$Username = "info@xxx.onmicrosoft.com" #Read-Host -Prompt "Please enter your username"

$Password = Read-Host -Prompt "Please enter your password" -AsSecureString

 

 

$ctx = new-object Microsoft.SharePoint.Client.ClientContext($siteUrl)

$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $Password)

 

$web = $ctx.Web

$ctx.Load($web);

$ctx.ExecuteQuery();

 

#load navigation nodes

$nav = $web.Navigation

$ctx.Load($nav)

$ctx.ExecuteQuery()

$srchNav = $nav.GetNodeById(1040);

[Microsoft.SharePoint.Client.NavigationNodeCollection] $sNodes = $srchNav.Children

$ctx.Load($srchnav)

$ctx.Load($sNodes)

$ctx.ExecuteQuery()

 

#delete navigation nodes

for ($nodeID=0;$nodeID -lt $sNodes.Count;$nodeID++)

    {

        $nNode = $sNodes[$nodeID];

        $nNode.DeleteObject() 

    }

$ctx.ExecuteQuery()

 

#Create navigation nodes

 

if ($addNodes) {

$node5 = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation

$node5.Title = $node5Title

$node5.Url = $node5Url

$node5.AsLastNode = $false

$node5.IsExternal = $true

$ctx.Load($sNodes.Add($node5))

 

write-host "Adding People"

$node4 = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation

$node4.Title = $node4Title

$node4.Url = $node4Url

$node4.AsLastNode = $false

$node4.IsExternal = $true

$ctx.Load($sNodes.Add($node4))

 

write-host "Adding Documents"

$node3 = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation

$node3.Title = $node3Title

$node3.Url = $node3Url

$node3.AsLastNode = $false

$node3.IsExternal = $true

$ctx.Load($sNodes.Add($node3))

 

write-host "Adding News"

$node2 = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation

$node2.Title = $node2Title

$node2.Url = $node2Url

$node2.AsLastNode = $false

$node2.IsExternal = $true

$ctx.Load($sNodes.Add($node2))

 

write-host "Adding Intranet"

$node1 = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation

$node1.Title = $node1Title

$node1.Url = $node1Url

$node1.AsLastNode = $false

$node1.IsExternal = $true

$ctx.Load($sNodes.Add($node1))

}

$ctx.ExecuteQuery()