Skip to content

Instantly share code, notes, and snippets.

View estruyf's full-sized avatar
:octocat:
Front Matter CMS

Elio Struyf estruyf

:octocat:
Front Matter CMS
View GitHub Profile
@estruyf
estruyf / Control_Refresh.html
Created December 3, 2014 08:18
SPSUK Demo Refreshing results (Control template)
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<title>Refresh Results</title>
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string">This is the default Control Display Template that will list the items. It does not allow the user to page through items.</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106601</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#Content Web Parts;#</mso:TargetControlType>
@estruyf
estruyf / Control_More.html
Created December 3, 2014 08:19
SPSUK Demo Loading more results (Control Template)
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<title>More Results</title>
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string">This is the default Control Display Template that will list the items. It does not allow the user to page through items.</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106601</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#Content Web Parts;#</mso:TargetControlType>
@estruyf
estruyf / Control_Group.html
Created December 3, 2014 08:20
SPSUK Demo Grouping (Control template)
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<title>Grouping Template</title>
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string"></mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106601</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#Content Web Parts;#</mso:TargetControlType>
@estruyf
estruyf / Item_Group.html
Created December 3, 2014 08:21
SPSUK Demo Grouping (Item template)
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<title>Item Group</title>
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:ManagedPropertyMapping msdt:dt="string">'Link':'Path','Line 1'{Line 1}:'Title','Grouping':'SiteTitle'</mso:ManagedPropertyMapping>
<mso:MasterPageDescription msdt:dt="string"></mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId>
@estruyf
estruyf / Retrieve list name via REST.js
Last active August 1, 2020 04:50
Retrieve the list name in a display template
Type.registerNamespace('search.listname');
search.listname = function () {
var itemInfo = {};
var listInfo = {};
var init = function (context, elmId) {
// Store item info
itemInfo[elmId] = {};
itemInfo[elmId]["webUrl"] = context.CurrentItem.SPWebURL;
@estruyf
estruyf / Refiner.js
Created January 24, 2015 09:42
Search refiner DateTime
var $v_2 = Srch.ValueInfo.ValueTypeHandler.$2J('DateTime', [ 'LastModifiedTime', 'Created', 'DiscoveredTime', 'DisplayDate', 'EndDate', 'ExpirationTimes', 'ExtractedDate', 'ImageDateCreated', 'processingtime', 'StartDate' ], [ 'OWSDATE' ], [ 'DateTime' ], Srch.ValueInfo.Renderers.defaultDateRenderer);
@estruyf
estruyf / value type handling.js
Created January 26, 2015 14:49
Value type handling in refiners
// Checks if the value type is known managed properties
a = Srch.ValueInfo.ValueTypeHandler.$2Q(b, d, Srch.ValueInfo.ValueTypeHandler.$k);
// If the propert is unknown, check the managed property suffix (OWSDATE, OWSHTML, ...)
if (Srch.U.n(a)) {
// Retrieve the ows suffix
var f = Srch.ValueInfo.$d(b);
// Retrieve the value type by the suffix
a = Srch.ValueInfo.ValueTypeHandler.$2Q(f, d, Srch.ValueInfo.ValueTypeHandler.$30)
}
@estruyf
estruyf / trick refiner.js
Created January 26, 2015 15:11
Trick the refiner into thinking it is a date and time MP
var propertyName = ctx.RefinementControl.propertyName;
// Let the refiner think it is a datetime field, needed for custom managed properties
ctx.RefinementControl.propertyName = trickDateProperty(propertyName);
// Retrieving the labels
ctx.BucketedFilterData = AjaxControlToolkit.SliderRefinementControl.GetDefaultBuckets(ctx);
// Reset the property name
ctx.RefinementControl.propertyName = propertyName;
@estruyf
estruyf / Datepicker refiner code.js
Created January 28, 2015 09:51
Range Filter with datepicker code
$includeCSS(this.url, 'https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css');
RegisterSod('jquery-1.11.0.min.js', "//code.jquery.com/jquery-1.11.0.min.js");
RegisterSod('jquery-ui.min.js', '//code.jquery.com/ui/1.11.1/jquery-ui.min.js');
RegisterSodDep('jquery-ui.min.js', 'jquery-1.11.0.min.js');
Type.registerNamespace('estruyf.range');
estruyf.range.datepicker = function() {
var container = {};
@estruyf
estruyf / Call the daterange init function.js
Created January 28, 2015 09:51
Call the daterange init function
Srch.U.getRenderTemplateCollection().daterange_init(controlID, fromInput, toInput);