I built this using a CSWP and a custom Display Template.
In CSWP you have to restrict the search to only return Sites (Query string = "contentclass:STS_Web
" ) and sort the results either by Url
or SPSiteUrl
.
Then you create a custom Display Template (simplest way is to copy an modify the file Item_Site.html in MasterPage Gallery -> Display Templates -> Search.) Let's call it Item_Site_Nav.html
.
Then edit the Item_Site_Nav.html-list item's properties and add 'UrlDepth':UrlDepth'
to the Managed Properties.
And lastly set this Display Template in the CSWP Display Settings.
My modified Item_Site_Nav.html looks like this. I think it could be stripped some more.
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<title>Website for Navigation</title>
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string">Website for navigation.</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#SearchResults;#</mso:TargetControlType>
<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>
<mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title','Path':'Path','SiteLogo':'SiteLogo','SiteDescription':'SiteDescription','CollapsingStatus':'CollapsingStatus','DocId':'DocId','HitHighlightedProperties':'HitHighlightedProperties','FileExtension':'FileExtension','ViewsLifeTime':'ViewsLifeTime','deeplinks':'deeplinks','importance':'importance','FileType':'FileType','UrlDepth':'UrlDepth'</mso:ManagedPropertyMapping>
<mso:CrawlerXSLFile msdt:dt="string"></mso:CrawlerXSLFile>
<mso:HtmlDesignPreviewUrl msdt:dt="string"></mso:HtmlDesignPreviewUrl>
<mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded>
<mso:HtmlDesignStatusAndPreview msdt:dt="string">http://spoint.netze-duisburg.loc/_catalogs/masterpage/Display Templates/Search/Item_SiteIndentation.html, Konvertierung erfolgreich.</mso:HtmlDesignStatusAndPreview>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>
<body>
<div id="Item_Site">
<!--#_
if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){
var urlDepth = ctx.CurrentItem.UrlDepth;
var indentation = ''; //'<span>- </span>'.repeat(urlDepth);
for (i=0; i<urlDepth; i++) {
indentation = indentation + "<span> </span>";
}
_#-->
<div>_#= indentation =#_<a href="_#= ctx.CurrentItem.Path =#_">_#= ctx.CurrentItem.Title =#_</a></div>
<!--#_
}
_#-->
</div>
</body>
</html>
The indentation span-element can be replaced with whatever CSS/html you like.
Don't forget to publish your custom display template.
Cheers,
Ben