We have invested in Sharepoint 2013 and I'm trying to write some customised Display Templates.
A sample of the code I am working on appears below.
I was struggling with some aspects of this, to the extent that I required an MS Support Paid Incident to resolve a simple issue like surfacing Managed Meta Data. That issue took an MS Support engineer around 2 weeks to resolve.
I am now experiencing additional problems, specifically trying to understand the values and properties that are returned from the Ctx.CurrentItem.XXX methods and objects.
I have done a lot of Googling and come to the conclusion that what I am looking for is the Sharepoint 2013 JSOM Reference. However, somewhat frighteningly, this does not appear to exist? I have been able to find some pages that show samples of how the JSOM can be used, but it seems that the Reference itself has never been released? Can anybody point me to a link, or confirm for me that, as yet, the Reference is not available?
By way of clarification, I am looking for the official reference that explains in detail each of the methods and properties and what types of data they return etc.
For an example of what I mean by Reference - , in .NET Framework, if I want specific documentation on the FileInfo class, I can look here:
http://msdn.microsoft.com/en-us/library/system.io.fileinfo(v=vs.100).aspx
and I see an exact definition of the class, its method and properties that are available, together with specific documentation as to exactly what they do, what will be returned etc. That's what I mean byReference - the actual official technical documentation for the product.
Where can I find this information for the JSOM for Sharepoint 2013?
I need to understand, for example, what is returned by ctx.CurrentItem.ContentType - at the moment, I am guessing that it returns an array of some type, but I am just having to guess based on the code I am writing and how it behaves. I am basically developing with a trial & error mentality, because I have no other information. Where I can find the information that I need?
I have already been through the following pages and their corresponding links, but none points to any official reference or the information I am looking for:
http://msdn.microsoft.com/en-us/library/jj163201.aspx
http://msdn.microsoft.com/en-us/library/ee552096.aspx
These talk about the object model, how it can be used, and talk about where to find various .js files. But nowhere is there any links to documentation of the model itself?
Where can I find information about the ctx Object and the methods and properties that I can use with it, when working with Customised Display Templates?
Has this documentation ever been released?
Thanks
Robert
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> <head><title>PDF Item Full Preview 4</title><!--[if gte mso 9]><xml><mso:CustomDocumentProperties><mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden><mso:MasterPageDescription msdt:dt="string">Displays a result tailored for a Portable Document Format (PDF) document.</mso:MasterPageDescription><mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId><mso:TargetControlType msdt:dt="string">;#SearchResults;#</mso:TargetControlType><mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated><mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title','Path':'Path','Description':'Description','EditorOWSUSER':'EditorOWSUSER','LastModifiedTime':'LastModifiedTime','CollapsingStatus':'CollapsingStatus','DocId':'DocId','HitHighlightedSummary':'HitHighlightedSummary','HitHighlightedProperties':'HitHighlightedProperties','FileExtension':'FileExtension','ViewsLifeTime':'ViewsLifeTime','ParentLink':'ParentLink','FileType':'FileType','IsContainer':'IsContainer','SecondaryFileExtension':'SecondaryFileExtension','DisplayAuthor':'DisplayAuthor','ContentType':'ContentType','SPContentType':'SPContentType'</mso:ManagedPropertyMapping><mso:CrawlerXSLFile msdt:dt="string"></mso:CrawlerXSLFile><mso:HtmlDesignPreviewUrl msdt:dt="string"></mso:HtmlDesignPreviewUrl><mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded><mso:HtmlDesignStatusAndPreview msdt:dt="string">http://dev8spt/_catalogs/masterpage/Display Templates/Search/Item_PDF_FullPreview.html, Conversion successful.</mso:HtmlDesignStatusAndPreview></mso:CustomDocumentProperties></xml><![endif]--></head><body><div id="Item_PDF"><!--#_ if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){ var id = ctx.ClientControl.get_nextUniqueId(); var itemId = id + Srch.U.Ids.item; var hoverId = id + Srch.U.Ids.hover; var hoverUrl = "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_PDF_FullPreview_HoverPanel.js"; $setResultItem(itemId, ctx.CurrentItem); var k = ctx.DataProvider.get_currentQueryState().k; if(!Srch.U.e(k)){ ctx.CurrentItem.csr_Path = ctx.CurrentItem.Path + "#search=" + $urlKeyValueEncode(k); } ctx.CurrentItem.csr_Icon = Srch.U.getIconUrlByFileExtension(ctx.CurrentItem); ctx.CurrentItem.csr_OpenControl = "PdfFile.OpenDocuments"; ctx.currentItem_ShowHoverPanelCallback = Srch.U.getShowHoverPanelCallback(itemId, hoverId, hoverUrl); ctx.currentItem_HideHoverPanelCallback = Srch.U.getHideHoverPanelCallback(); if($isNull(ctx.CurrentItem.ContentType)){ _#--><div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="PDFItem" 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><!--#_ } else { switch(ctx.CurrentItem.ContentType) { application/pdf Architect Record case "application/pdf Architect Record": _#--><div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="PDFItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_"><table><tr><td> Icon</td><td> RegistrationNumber Surname Forenames</td></tr><tr><td>Content Type</td><td>ArchitectsRecordCategory Name</td></tr></table><div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div></div><!--#_ break; default: _#--><div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="PDFItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_"> _#=ctx.CurrentItem.ContentType=#_ _#=ctx.RenderBody(ctx)=#_<div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div></div><!--#_ break; } } } _#--></div></body></html>