Creating a custom display template for search we're facing this request: the search result item should show first the item hyperlink, then some managed properties and finally the item summary.

In the default template normally this is used to show item summary and link to element:

<div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="DefaultItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_">
     _#=ctx.RenderBody(ctx)=#_
    <div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div>
</div>

But what can we use or what to do if we want to get only the item summary?

Update: just found a snippet from "Item_CommonItem_Body.html" template:

<div id="_#= $htmlEncode(id + Srch.U.Ids.summary) =#_" class="ms-srch-item-summary">_#= Srch.U.processHHXML(ctx.CurrentItem.HitHighlightedSummary) =#_</div>

according to this blog

Could this do the trick?

有帮助吗?

解决方案

we approved that we can use the snippet from "Item_CommonItem_Body.html" template:

<div id="_#= $htmlEncode(id + Srch.U.Ids.summary) =#_" class="ms-srch-item-summary">_#= Srch.U.processHHXML(ctx.CurrentItem.HitHighlightedSummary) =#_</div>

We only have to care that "HitHighlightedSummary" is included in the ManagedPropertyMapping

<mso:ManagedPropertyMapping msdt:dt="string">'HitHighlightedSummary':'HitHighlightedSummary',...</mso:ManagedPropertyMapping>
许可以下: CC-BY-SA归因
scroll top