Advanced widget templates

An example on how to implement multiple advanced widgets with custom templates

The use of custom templates can really make a big difference in how you use searchine. Three examples of this are lower on this page. The first one shows just some styling changes. And the other two have pre filtered results and are shown as cards.

Code:

<script type="text/javascript">
   window._sn = window._sn || [];
   window._sn.config = {
    remoteApiUrl: '[--engineid--]',
   };
  window._sn.searchpages = [];
   window._sn.searchpages.push({
      engineid: '[--engineid--]',
      container: '#searchinenet',
   });
window._sn.searchpages.push({
engineid: '[--engineid--]',
container: '#searchinenet-cards',
templatePrefix: 'cardExample-', // template prefix so you can specify other templates per widget
disableSearchField: true, // Prevents the widget from getting or setting data into the url

pushStateToUrl: false, // don't alter the URL after every search attempt
restoreStateFromUrl: false, // don't read the URL for retrieving search settings
afterInit: function () {

var that = this;
if (that.IsInitialRequest()) {

var configuration = {
// Can be used to pre set facets and or spatial configuration like orderByDistance or withinRadius
};
window.sp = this;
window.sp.SetConfiguration(configuration);

window.sp.SetKeywords("widget");
window.sp.TriggerSearch();
}
}
});
window._sn.searchpages.push({

engineid: '[--engineid--]',
container: '#searchinenet-cards-all',
templatePrefix: 'cardExample-',
allowEmptySearchField: true, // Allows the widget to search witout search text
disableSearchField: true,// Prevents the widget from getting or setting data into the url
pushStateToUrl: false,
restoreStateFromUrl: false,
afterInit: function () {

var that = this;
if (that.IsInitialRequest()) {

var configuration = {
// Can be used to pre set facets and or spatial configuration like orderByDistance or withinRadius
};
window.sp = this;
window.sp.SetConfiguration(configuration);

window.sp.TriggerSearch();
}
}
});
</script>
Basic widget
Widget cards

Cards based on the search text "widget"

Cards

Cards for all results

404 Page with search results