Last active
September 15, 2018 00:34
-
-
Save mish15/4dfe702f8f6c0925f65fabd8bd91d3a6 to your computer and use it in GitHub Desktop.
MNYS install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: global search box | |
// Put into main template (all pages) | |
// Assumes ID of search box will remain unchanged: CT_Header_0_ctl01_txtSearch | |
var getUrlParam = function(e){var t = new RegExp("[?&]" + e.replace(/[\[\]]/g, "\\$&") + "(=([^&#]*)|&|#|$)"),a = t.exec(window.location.href);return a && a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : ""}; | |
var setup = function(w,d,x,a,e,s,c,r){s = [];var b=function(){s.push(arguments);},q="ui";b.arr=s;w[a]=w[a]||[];w[a][q]=w[a][q]||[];w[a][q].push(b);c=d.createElement(x);c.async=1;c.src=e;r=d.getElementsByTagName(x)[0];r.parentNode.insertBefore(c,r);return b;}; | |
var searchBox = setup(window, document, "script", "sajari", "//cdn.sajari.net/js/integrations/website-search-1.4.js"); | |
searchBox({ | |
mode: "search-box", | |
project: "1520368576952702052", // Set this to your project. | |
collection: "www-mnys-org", // Set this to your collection. | |
instantPipeline: "autocomplete", // Pipeline used as you type | |
inputPlaceholder: "Search", // Input element placeholder | |
maxSuggestions: 5, // Maximum number of suggestions to show | |
attachSearchBox: document.getElementById("CT_Header_0_ctl01_txtSearch") // DOM element to attach to | |
}); | |
// When the user searches, this will send them to the results page | |
searchBox("sub", "pipeline.search-sent", function (_, query) { | |
window.location = "/search/?q=" + encodeURIComponent(query.q); | |
}); | |
// --------------------------------------------------------------- | |
// Step 2: search results page | |
// 2a: Add HTML to the page where the GSS results are currently: | |
<div id="results-search-box"></div> | |
<div id="results-search-response"></div> | |
// --------------------------------------------------------------- | |
// 2b: add the following JavaScript to the search results page template: | |
var searchInterface = setup(window, document, "script", "sajari", "//cdn.sajari.net/js/integrations/website-search-1.4.js"); | |
searchInterface({ | |
mode: "inline", | |
project: "1520368576952702052", // Set this to your project. | |
collection: "www-mnys-org", // Set this to your collection. | |
pipeline: "website", // Set the search pipeline. | |
instantPipeline: "autocomplete", // Set the instant pipeline. | |
attachSearchBox: document.getElementById("results-search-box"), // DOM element to render search box. | |
attachSearchResponse: document.getElementById("results-search-response"), // DOM element to render search results. | |
inputPlaceholder: "Search", // Placeholder text for the search box. | |
inputAutoFocus: false, // Focus the input element on render. | |
maxSuggestions: 5, // Maximum number of suggestions to show. | |
results: {"showImages": true }, // Configure the results. | |
values: {"q.override": true, "resultsPerPage": "10","q": getUrlParam("q")}, // Set default values. | |
tabFilters: {defaultTab:"All",tabs:[{title:"All",filter:""},{title:"Faith",filter:"dir1='faith'"},{title:"For Leaders",filter:"dir1='for-leaders-and-congregation'"},{title:"News & Events",filter:"dir1='news-and-events'"}]}, // User selectable filters | |
styling: { theme: { colors: { brand: { primary: "#bfb3f3" }}}} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment