In SharePoint 2013 we have display templates to handle the display of search results in web parts. I would recommend to read this msdn article to understand display templates first.
I will give a walk through on how do we customize a display template for a particular requirement (in this case to display e-mail address of person).
Prerequisites: Search should be configured and working in the
system.
Solution:
1.
Create a web part page “MySearch.aspx”, and
added “Search Box” & “Search Results” web parts.
2.
Configure both the web parts that search box
query goes to search result.
3.
Go to Site Settings
-> Master Page Gallery -> Display Templates -> Search
4.
Download “Item_Person.html” file, the display
template for People Item.
5. Change html to display Email – add the highlighted code as below:
6.
Upload the updated file to display template
library and publish the file.
7.
Go to the MySearch page -> Edit Page->
Edit ‘Search Results’ Web part
8.
Under ‘Display Templates’, chose ‘Use a single
template to display items’ and select ‘People Item’.
9. Save
and exit the Page.
10. Search
name in search box, it should return email id with People data.
No comments:
Post a Comment