Question

I've successfully created a new People display template (Item_Person.html) and associated result type, and used it on the peopleresults.aspx page. Now, I'm trying to achieve the same effect on the results.aspx page. According to @matthew-mcdermott in this post, it is using the Item_Person_CompactHorizontal.html display template so I've copied that template and created a corresponding result type. However, I cannot get the custom display template to be used on the results.aspx page. If I explicitly choose that template, it will show my changes but it does not when I select the template based on the result type.

Moreover, I cannot seem to locate an existing search service result type that utilizes the Item_Person_CompactHorizontal template, so perhaps this customization is not possible without editing the original template?

I've also documented my issue here, with screen shots.

Was it helpful?

Solution

The Item_Person_CompactHorizontal display template is triggered by a query rule on the Local SharePoint result source called "People Name in SharePoint Search".

Look up the query rules in the site collection site settings. Filter by Local SharePoint and you will find one called "People Name in SharePoint Search". When you view the settings, you will see that it adds a result block called People named {subjectTerms}. View the settings for the result block and you will see that it uses an item display template called "People Intent Item". That is the title of Item_Person_CompactHorizontal.

To make search use your display template instead, copy the OOTB query rule and tweak the settings in the result block. Once saved, make the OOTB version inactive.

EDIT After I wrote this, I realised that you tagged the question as O365. I only use on-premises so I can't confirm this all works exactly the same. From what I read, it should be though. I've fixed the link above to point to the SharePoint Online docs instead.

Licensing

Tracy pointed out that query rules that add result blocks or change ranked results are only available on certain O365 plans. Look for "Query rule - advanced actions" under the search section.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top