CSWP Sites Display Template

This is a downloadable display template that you install on your site collection to allow any Content Search Web Part (CSWP) to display sites, their icon and site description.  Also depending the type of site, other relevant information such as the number of Community site members, discussions, and replies are displayed.

Adding Sites Display Template to Site Collection

You must have manage hierarchy permissions or higher on the site collection home in order to upload new display templates.

1. Download and extract the 4 files from the zip file:

Upload the CSS file and icons

2. Add the CSS file and Icons to the Style Library at the Site Collection top site.

3. If there are the green checked out icons next to the files, click the checkbox next to the 3 files, select the Files tab, and Check In the 3 files.

4. Select Major version if presented with an option, click OK.

Upload the display template

5. Go to the Site Collection Site Settings, select the Master pages and page layouts option.

6. Click on the Display Templates folder

7. Click on the Content Web Parts folder

8. Click on the Files tab, select Upload Document

9. Click the Browse button

10. Find and select the Item_custom_sites HTML file that you extracted in Step 1.

11. The file properties window should popup, the Content Type, Title, Description, etc should all be pre-filled so just select Save.

12. Click the checkbox next to the Item_custom_sites.html file, click on the File tab, Check In (if option if available), then Publish (if option is available).

Add and configure the CSWP on a page

13. Go to a page and edit the page, Insert a Content Rollup > Content Search Web Part onto the page.  Edit the web part.

14. Click the Change query button.

15. Click the Switch to Advanced Mode option.

16. Edit the Query text, your query text could include the path to one or more sites, this would show all sites under the specified site or sites.  Append (contentclass=STS_Site OR contentclass=STS_Web) to show both subsites and site collection home sites (web).  You can also specify the type of sites using the WebTemplate property filter.

17. Click the Sorting tab, unfortunately you cannot sort by the SiteTitle by default.  You would need to go to Central Admin > Search Service Application > Search Schema, and make the SiteTitle sortable for the farm (requires a full crawl to take affect)

In the meantime you can sort by SiteNumFollowers, ViewsRecent and ViewsLifeTime, or if it’s a community site by the CommunityMembersCount Descending.  Click the OK button at the bottom to save your query.

18. Select how many items you want to display, select the Custom Sites Item display template, click OK to save the web part settings.

Your CSWP should now be displaying sites with the custom formatting and information depending on site type:

About Nick Hurst (85 Articles)
SharePoint and Nintex developer who strives to find easy to deploy and maintain solutions for business problems.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: