Recent

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.
cswp-disptemp-sites-1

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:
CustomSitesDispTemp.zip

Upload the CSS file and icons

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

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.
cswp-disptemp-sites-3

4. Select Major version if presented with an option, click OK.
cswp-disptemp-discussion-4

Upload the display template

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

6. Click on the Display Templates folder
cswp-disptemp-discussion-6

7. Click on the Content Web Parts folder
cswp-disptemp-discussion-7

8. Click on the Files tab, select Upload Document
cswp-disptemp-discussion-8

9. Click the Browse button
cswp-disptemp-discussion-9

10. Find and select the Item_custom_sites HTML file that you extracted in Step 1.
cswp-disptemp-sites-4

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

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).
cswp-disptemp-sites-6

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.
cswp-disptemp-discussion-14

14. Click the Change query button.
cswp-disptemp-discussion-15

15. Click the Switch to Advanced Mode option.
cswp-disptemp-discussion-16

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.
cswp-disptemp-sites-7

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.
cswp-disptemp-sites-8

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

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

About Nick Hurst (84 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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: