Skip to content

Instantly share code, notes, and snippets.

@estruyf
Created December 3, 2014 08:12
Show Gist options
  • Save estruyf/ad4f759321e2d9c16882 to your computer and use it in GitHub Desktop.
Save estruyf/ad4f759321e2d9c16882 to your computer and use it in GitHub Desktop.
SPSUK Demo Intellisense (item template)
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<title>Intellisense</title>
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:ManagedPropertyMapping msdt:dt="string">'Link URL'{Link URL}:'Path','Line 1'{Line 1}:'Title','Line 2'{Line 2}:'','FileExtension','SecondaryFileExtension'</mso:ManagedPropertyMapping>
<mso:MasterPageDescription msdt:dt="string">This Item Display Template will show a small thumbnail icon next to a hyperlink of the item title, with an additional line that is available for a custom managed property.</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#Content Web Parts;#</mso:TargetControlType>
<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>
<mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded>
<mso:HtmlDesignStatusAndPreview msdt:dt="string">http://intranet/sites/SPSUK/_catalogs/masterpage/SPSUK/Intellisense/Item_Intellisense.html, Conversion successful.</mso:HtmlDesignStatusAndPreview>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>
<body>
<script>
// Get search data function
function getSearchDataForTwoLines(ctx) {
var itemData = [];
var encodedId = $htmlEncode(ctx.ClientControl.get_nextUniqueId() + "_2lines_");
itemData["containerId"] = encodedId + "container";
itemData["linkURL"] = $getItemValue(ctx, "Link URL");
itemData.linkURL.overrideValueRenderer($urlHtmlEncode);
itemData["iconURL"] = Srch.ContentBySearch.getIconSourceFromItem(ctx.CurrentItem);
itemData["line1"] = $getItemValue(ctx, "Line 1");
itemData["line2"] = $getItemValue(ctx, "Line 2");
itemData.line1.overrideValueRenderer($contentLineText);
itemData.line2.overrideValueRenderer($contentLineText);
itemData["containerId"] = encodedId + "container";
itemData["pictureLinkId"] = encodedId + "pictureLink";
itemData["pictureId"] = encodedId + "picture";
itemData["dataContainerId"] = encodedId + "dataContainer";
itemData["line1LinkId"] = encodedId + "line1Link";
itemData["line1Id"] = encodedId + "line1";
itemData["line2Id"] = encodedId + "line2";
return itemData;
}
// Register function
Srch.U.registerRenderTemplateByName("getsearchdatafortwolines", getSearchDataForTwoLines);
</script>
<div id="TwoLines">
<!--#_
// Call the function
var itemData = Srch.U.getRenderTemplateCollection().getsearchdatafortwolines(ctx);
_#-->
<div class="cbs-Item" id="_#= itemData.containerId =#_" data-displaytemplate="Item2Lines">
<a class="cbs-ItemLink" title="_#= $htmlEncode(itemData.line1.defaultValueRenderer(itemData.line1)) =#_" id="_#= itemData.pictureLinkId =#_">
<img class="cbs-Thumbnail" src="_#= itemData.iconURL =#_" alt="_#= $htmlEncode(itemData.line1.defaultValueRenderer(itemData.line1)) =#_" id="_#= itemData.pictureId =#_" />
</a>
<div class="cbs-Detail" id="_#= itemData.dataContainerId =#_">
<a class="cbs-Line1Link ms-noWrap ms-displayBlock" href="_#= itemData.linkURL =#_" title="_#= $htmlEncode(itemData.line1.defaultValueRenderer(itemData.line1)) =#_" id="_#= itemData.line1LinkId =#_">_#= itemData.line1 =#_</a>
<!--#_
if(!itemData.line2.isEmpty)
{
_#-->
<div class="cbs-Line2 ms-noWrap" title="_#= $htmlEncode(itemData.line2.defaultValueRenderer(line2)) =#_" id="_#= itemData.line2Id =#_">_#= itemData.line2 =#_</div>
<!--#_
}
_#-->
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment