Enumerate all properties in Display Templates – Search Results

proicon_listsearchWe use Display templates to customize search results. By default there will be many properties fetched for each search item & only a few will be displayed (rendered) like Title, Summary, Path…

For getting remaining properties, you can always do below:

ctx.CurrentItem.<PropertyName>

Requirement:

To display all the properties of a search result item.

Resolution:

var finalTableInner = “<table class=’metadata_table’>”;
for(var p in ctx.CurrentItem)
{
finalTableInner += “” + p + “:” + $getItemValue(ctx, p) + “”;
}
finalTableInner += “</table>”;

Then you can show the above variable inside your required DIV like below

That is all folks. You can see the properties below


1: Rank:11.27
2: DocId:5367
3: WorkId:5367
4: Title:test123
5: Author:Developer
6: Size:0
7: Path:http://example.com/test/DispForm.aspx?ID=1
8: Description:
9: Write:Mon Jun 3 19:55:58 UTC+0300 2013
10: CollapsingStatus:0
11: HitHighlightedSummary:
12: HitHighlightedProperties:&lt;HHTitle&gt;&lt;c0&gt;test123&lt;/c0&gt;&lt;/HHTitle&gt;&lt;HHUrl&gt;
13: http://example.com/test/DispForm.aspx?ID=1&lt;/HHUrl&gt;&lt;author hashh=&quot;0&quot;&gt;Developer&lt;/author&gt;
14: contentclass:STS_ListItem_GenericList
15: PictureThumbnailURL:
16: ServerRedirectedURL:
17: ServerRedirectedEmbedURL:
18: ServerRedirectedPreviewURL:
19: FileExtension:aspx
20: ContentTypeId:0x0100…
21: ParentLink:http://example.com/test/AllItems.aspx
22: ViewsLifeTime:
23: ViewsRecent:
24: SectionNames:
25: SectionIndexes:
26: SiteLogo:
27: SiteDescription:
28: deeplinks:
29: importance:
30: SiteName:http://example.com
31: IsDocument:No
32: LastModifiedTime:Monday, June 3, 2013
33: FileType:
34: IsContainer:No
35: WebTemplate:
36: SecondaryFileExtension:
37: docaclmeta:
38: OriginalPath:http://example.com/test/DispForm.aspx?ID=1
39: EditorOWSUSER:Developer
40: DisplayAuthor:Developer
41: ResultTypeIdList:38;6
42: PartitionId:0c37852b-34d0-418e-91c6-2ac25af4be5b
43: UrlZone:0
44: AAMEnabledManagedProperties:AttachmentURI;deeplinks;DefaultEncodingURL;ExternalMediaURL;HierarchyUrl;
45: OrgParentUrls;OrgUrls;OriginalPath;ParentLink;Path;PictureThumbnailURL;PictureURL;PublishingImage;
46: recommendedfor;ServerRedirectedEmbedURL;ServerRedirectedPreviewURL;ServerRedirectedURL;SiteLogo;
47: SitePath;SPSiteURL;UserEncodingURL
48: ResultTypeId:38
49: RenderTemplateId:~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_test.js
50: piSearchResultId:0_1
51: ParentTableReference:[object Object]
52: csr_id:ctl00_PlaceHolderMain_ctl01_csr2_item
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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

Powered by WordPress.com.

Up ↑

%d bloggers like this: