How to: Create a Simple SharePoint 2013 People Directory

June 9, 2013 — Leave a comment

Source: http://www.sharepointconfig.com/2013/05/how-to-create-a-simple-sharepoint-2013-people-directory/
Written by Ari Bakker

A people directory can be useful if you want to list all the people in an organisation without users having to enter a search query. Users can then narrow down the list using filters such as Department or Job Title to narrow the results. This is really easy to set up using the default SharePoint 2013 search web parts and doesn’t require writing a single line of code. An example of what this can look like is shown below:

sharepoint people directory

Especially when the organisation only contains a few hundred people this can help users discover people in the organisation without necessarily knowing their names. The steps to create this are as follow (assuming the user profile and search services are running successfully):

  1. Assuming you have an enterprise search center set up the first step to create the people directory is to enable the people search page layout so we can create a people search results page. This can be done by navigating to the Site Settings > Look and Feel | Page layouts and site templates page and selecting ‘(Welcome Page) Search People’ in the Page Layouts section.
    sharepoint available page layouts search
  2. The next step is to navigate to the pages library and select New Document > Page from the ribbon.
    sharepoint new page
  3. On the create page screen select the Search People page layout to create a page that contains the people search results web parts.
    sharepoint create people results page
  4. The standard search result web part does not show any results unless a query is specified. To get all people to show up by default we need to modify the query used by the People Search Core Results web part. This can be done by clicking the ‘Change Query’ button in the web part properties and adding a property filter that returns all people. To do this we can select the property ‘contentclass’ and enter the manual value ‘spspeople’.
    sharepoint search build query
  5. We now have a list of people that will be displayed as soon as the user navigates to our custom people results page. By default we also have some refinements that appear if matching metadata is found within the result set. These are the Department, Job Title, Keywords and Office Location columns. We can change these to show other metadata properties that are defined in our search centre by selecting the ‘Choose refiners’ option on the refinement web part. Note that the managed property must have the ‘Refinable’ option selected in the search schema for it to be available in this list.
    sharepoint search refinements

Adding Sorting by Last Name

Adding additional sort options is much easier than in SharePoint 2010. To add a custom sort option such as Last Name follow the steps below:

  1. Ensure that the managed property you want to sort by has the Sortable option enabled in the search schema. To do this navigate to the Search Service Application > Search Schema, click the LastName managed property and select the Sortable: ‘Yes – active’ option. Note you will need a full crawl for this to take effect.
    sharepoint 2013 managed property sortable
  2. On the search results page edit the People Search Core Results web part, check the ‘Show sort dropdown’ option and enter the following text:
    [{"name":"First name (A-Z)","sorts":[{"p":"FirstName","d":0}]},{"name":"First name (Z-A)","sorts":[{"p":"FirstName","d":1}]},{"name":"Last name (A-Z)","sorts":[{"p":"LastName","d":0}]},{"name":"Last name (Z-A)","sorts":[{"p":"LastName","d":1}]},{"name":"Social distance","sorts":[]}]sharepoint search sorting
  3. You should now be able to sort by first or last name in alphabetical order either A-Z or Z-A.
    sharepoint search people sorting

Using a Table Based Layout

Another option for the people directory is to use a table based layout with column headers for properties. In SharePoint 2013 this can be done using Display Templates. In this case we need to use two display templates – a control template for the table header, and a item template for each search result item. The steps to implement this are shown below.

  1. The first step is to add the display templates to the masterpage gallery by selecting Site Settings > Master Pages and Page Layouts > Display Templates > Search and upload the two html files from the following .zip archive.
    PeopleDirectoryDisplayTemplates.zip
  2. The next step is to edit the search core results web part and in the Display Template section set the Results Control Display Template to ‘Table Result’ and the Item Display Template to ‘People Table Item’.
    sharepoint search display template selection
  3. You should now see the results displayed as a table based layout as shown below:

sharepoint people directory table

If you have worked with previous versions of SharePoint you can see that in SharePoint 2013 the search features are much richer and easier to work with. There are also a number of new features such as query rules and extensibility options such as customising the hover panel that enhance the end user search experience.

Source: http://www.sharepointconfig.com/2013/05/how-to-create-a-simple-sharepoint-2013-people-directory/
Written by Ari Bakker

No Comments

Be the first to start the conversation!

Leave a Reply

Please log in using one of these methods to post your comment:

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