If you took a peek at SharePoint 2013 recently, you may have noticed there is a new Site Collection called the Community Site Portal. This new site works in conjunction with the Community Site template. In short, it’s a site that shows you a list of all Community Sites. My goal is to do the same thing but for other types of Sites, for example a Team Site portal.
A look at how the existing Search Portal works
Best way to understand how SharePoint works is sometimes to dig in to what is presented in front of us. Something quickly jumped at me when I looked at the Community Site Portal, there is a “number of results” shown at the bottom of the page and changes made to the Community Site do not appear immediately. My first thought is that it must be based on the new SharePoint 2013 Search engine. As I mentioned in a previous article, we can leverage the power of search now with the Content Search Web Part or the Search Results to build our sites.
Let’s begin by editing the page and see how this has been built:
As you can see, the portal is nothing more than the result of a Search Query. It looks like the Content Search Web Part was added with a pre-configured Search Criteria and a custom Display Template. All we need to do now is take a look at the default Query and adapt it to our needs.
The default Search query for the SharePoint 2013 Community Site Portal
Essentially there is no manual search here; the Web Part is configured with a Search Criteria or a query if you want to display the Community Sites below. We can try to understand it a little better by clicking on the Change Query button in the Web Part properties.
Then we will have the new SharePoint 2013 Query Builder that is used in many Search Web Parts and settings. Within the Query Builder, we can see right away how it is able to get all the Community Sites for the Portal. And frankly, I am surprised at how easy it is to get it.
The Query simply says to grab “WebTemplate:Community”; in other words go get all the Sites that are built with the WebTemplate called Community.
Making a SharePoint 2013 Team Site Portal with Search
My first objective is to change the query for the Web Part to something that will get only Team Sites instead of Community Sites. What I did is created a new Site Collection to do my tests based on the Team Site Template. I then Activated the Publishing Infrastructure Site Collection Feature. Finally I created a blank Wiki page in Site Pages and added the Content Search Web Part on it.
I jumped to the Query Builder of my new Content Search Web Part and doing something I covered recently in “Rolling up SharePoint Sites with Content Search” I erased the Query Text box with whatever query was there by default. Then in the Keyword Filter dropdown menu, I selected the “Return Only Sites” option.
Why am I selecting this Keyword Filter?
That’s an excellent question, technically I could just modify the “WebTemplate:Community” by one that represents the Team Site WebTemplate.
In this scenario, I am assuming that we do not know what the WebTemplate names are.
By selecting this Keyword Filter and only returning sites, we can jump to the “Refiners” tab in the Query Builder at the top and let SharePoint do the work for us.
Awesome! Now I know how to write the value for my Query Text. Instead of using “WebTemplate:Community” I can try “WebTemplate:STS” for Team Sites for example.
Let’s go back to the Query Text box and type in our new value:
Let’s try it out, click on Ok and Save or Apply your changes to see your page again.
Now you can build your own SharePoint 2013 content search Site Portal based on any Site Template you want to. You could even push this even further by customizing the Query with other Site Properties. The issue is always in finding what these properties are.
Let’s see if it works with our Blogs as well:
I am really happy to see how easy it to change the Content Search, even as a Power User I can see this being very helpful to many.
Making it look like the Community Portal – Using the Display Templates
So we managed to build our own SharePoint 2013 Site Portal for Team Sites or even Blogs. But something is missing, the look and feel of the Portal. In my previous post on the Content Search, I already talked about Display Templates and how to change the property mapping to put the values of the properties we want in our favorite Display Template.
Unfortunately, none of the default Content Search Display Templates matches the look and feel we got from the Community Portal. So I am going to cheat and do something I learned with the Content Query Web Part back in SharePoint 2007 and SharePoint 2010. The trick is to export the Web Part found on the Community Portal on to your Desktop and Edit it with Notepad. I noticed that it gets it’s Display Template for items in a System folder of the Site Collection Catalog.
<property name="ItemTemplateId" type="string">~sitecollection/_catalogs/masterpage/Display Templates/System/Item_CommunityPortal.js</property>
I have a few options; I can export my Content Search Web Part and add the same links for the same properties as the ones in the Community Portal. I can Copy Paste the Display Template from the System folder to Content Web Parts in the Display Templates folder. Obviously I do not recommend the ladder but I do understand that sometimes we just do not have the luxury. You can also go directly to the Display Template stored in the System folder of the Display Templates and change the hidden value from 1 to 0. You will then be able to use it in your Content Search.
Another great reason to upgrade to SharePoint 2013
The more I dig into these Content Search and Search Results Web Part the more I love SharePoint 2013. Granted there are some limitations where you will need to “Extend” the Web Part by exporting it and editing the .webpart file on your desktop but for the most part it will satisfy our needs. Now you can build your own SharePoint Site Portal with any WebTemplate (Site Template) available and if you want, you can even push the Query further by limiting the UrlDepth for example (only show up to 2 subsites). Finally, make sure to choose the correct Display Template or build one as it makes all the difference. This was a response to some of the questions I got and posted on “What People want from SharePoint 2013” – be sure to visit that article to see other solutions.
If you haven't tried our popular SharePoint migration tool yet, what are you waiting for? ShareGate Desktop's UI isn't just simple and intuitive—it'S actually pleasant to use (really!).
Migrate to SharePoint or Office 365 quickly and easily, with best-in-class migration for all versions of SharePoint, unlimited data, and custom reporting. And effortlessly reorganize and restructure your content until it's exactly how you want it.
Save time and migrate with total peace of mind, then get back to business as usual. See for yourself with a free, full-featured 15-day trial.