I use Display Templates for rendering ContentBySearchWebPart. Nice feature, but how I can add custom properties from search results list item into Display Template?
For example, I have a template, some_listitem_template.html
:
<!--#_
var line1 = $getItemValue(ctx, "Line 1");
var line2 = $getItemValue(ctx, "Line 2");
var line3 = $getItemValue(ctx, "Line 3");
for (var p in ctx.CurrentItem)
{
console.log(p + ":" + $getItemValue(ctx, p));
}
line1.overrideValueRenderer($contentLineText);
line2.overrideValueRenderer($contentLineText);
_#-->
<div class="news-date">_#= line3 =#_</div>
<div class="news-title">
<a href="_#= linkURL =#_" title="_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_">_#= line2 =#_</a>
</div>
And I have Property Mapping declaration string
<mso:ManagedPropertyMapping msdt:dt="string">'Link URL':'Path','Line 1':'Title','Line 2':'Description', 'Line 3':'Created'</mso:ManagedPropertyMapping>
But these properties (Description and Created) is always empty. Debug information from console.log
show me that ContextItem
has a pretty small collection of properties:
Rank:0
DocId:46734
Path:http://someurl/news/Page-1.aspx
Title:Some title
FileExtension:aspx
SecondaryFileExtension:aspx
OriginalPath:somepath
PartitionId:0c37852b-34d0-418e-91c6-2ac25af4be5b5
UrlZone:1
AAMEnabledManagedProperties:AttachmentURI;deeplinks;DefaultEncodingURL;ExternalMediaURL;HierarchyUrl;OrgParentUrls;OrgUrls;OriginalPath;ParentLink;Path;PictureThumbnailURL;PictureURL;PublishingImage;recommendedfor;ServerRedirectedEmbedURL;ServerRedirectedPreviewURL;ServerRedirectedURL;SiteLogo;SitePath;SPSiteURL;UserEncodingURL
RenderTemplateId:~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default.js
QueryRuleId:00000000-0000-0000-0000-000000000000
Suppose its because Search Configuration, but where is this place exactly?
CommentsOWSMTXT
andArticleStartDateOWSDATE
for my purposes. These fields is indexed and mapping to ordinary Article Content Type columns and Display Tempalte works just fine.grunt deploy
. Take a look, for example generator-sp2013.