Setting up navigation based on search for Site collections

At the moment we are creating a portal based on host named site collections. The root site collection needs to display the sub site collections you have access to.

To give you a better understanding of what we created take a look at the following image:

blog-structure

Every site in the above image is a host named site collection. We are using separate site collections to be able to move sites between databases because the sites them selves will contain a large amount of data.

For the creation of the sub site collection we have created a custom provisioning method. How to do this provisioning can be read in my other article:

But now we had the challenge to display all the sites the current user has access to on the root site.

When we had setup the environment with the host named site collection it was time to create the representation of the sites on the root site (http://root).

First of all we started by adding the “Content Search” web part to the page that can be found in the “Content Rollup” category.

image

This web part will display several results already based on a empty search query. By editing the web part you will be able to define your own query.

image

Select the “Change Query” button to start defining your own query. Right away click on the “Switch to Advanced Mode” to start writing your own query. In the advanced window you will have a textbox to define a custom query.

image

Take a look at the following query we defined:

contentclass:STS_Site Path:{Site.Url}* Site<>{Site.Url}

The explanation of the query is the following:

  • contentclass:STS_Site : This will return every object within SharePoint that is of the type STS_Site. STS_Site stands for Site Collection. You also have STS_Web that stands for Web Site.
  • Path:{Site.Url}* : This will return only the sites that start with the current URL or have the current URL in the path variable. This means you will also retrieve the current site as a result.
  • Site<>{Site.Url} : This will return everything but the current site.

So by using this query you will retrieve every site collection under (URLwise) the current site collection that you have access to (Because search results are security trimmed).

For displaying these sites you can use several out of the box managed properties. Save the query by clicking “OK”. Then in the edit properties window extend the “Property Mappings” section.

image

In the screen shot above you can see several properties of a site that then result in the following:

image

The title’s links to the correct site. The logo’s of the sites are displayed when they have a custom logo attached. The description is also displayed and because we do not have any owners specified in this demo you can not see the result of this.

Within a custom portal you also have the option of using property bag properties within your search queries or your results, how this can be accomplished can be read here:

Related Posts

Forcing a Device Channel Device channels are a way of using different master pages for different devices. MSDN describes the functionality as followed:   “Browsing ...
Offline Installation SharePoint 2013 In many situation you would like to do a offline installation of SharePoint 2013 or you are required to do a offline installation because you do not h...
User automatically removed from SharePoint Group During my current project we received an access request from a user. We did what we normally do, we checked the request and added the user in the appr...
Unable to start User Profile Synchronization Service A few days ago I wrote a post about loading modules in PowerShell by default: “Load modules by default when opening PowerShell”. Today we had to setup...
Filtering SharePoint Search Results by Content Source Working for one my projects we were looking for a solution to only retrieve search results for a specific Content Source. In our scenario we had a Ext...
PowerShell Scripts During my current project we are using a lot of PowerShell scripts to administrate the environment and make development easier for us. In this post...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.