Add search options to the search results page
Before you start
- You need access to the Control Panel with permission to manage the Developer Framework.
Note: This script is a sample, not officially supported by Interact Technical Support. Review and test it with your development team before use, as it may need amends to work in your environment.
Overview
Your intranet is often the main site your users work in and, with features such as the application links bar, acts as a gateway to other systems. This is true for search. Interact has a number of search integrations, including SharePoint and Google Drive. Where no integration is available, you can add a new tab to the search results page so that a user can select it to open the target system in a new window and pass the search term through.
A user can then perform a search within the intranet and, from there, run the same search in a different system, for example Confluence.
Add the JavaScript below to MasterPage JavaScript in the Developer Framework. Once saved, when a user performs a new search they see a tab (in this example, ServiceNow) that opens a new window to the specified URL. The example uses a generic ServiceNow instance, so adjust it to your needs. You can use this approach to add as many tabs as you want.
// Set some variables for the servicenow instance.
var servicenowDomain = "www.service-now.com/search_sp?&q=";
function searchservicenow() {
// Open a new window to the specified URL and add the search term.
var searchTerm = $('input[type=search]')[0].value;
var url = "https://" + servicenowDomain + encodeURI(searchTerm) ;
window.open(url, '_blank').focus();
}
window.setTimeout(function () {
// build the HTML for the tab
var servicenow = '<li><a href="javascript:void(0)" onclick="searchservicenow()" role="tab" aria-selected="false" class="">ServiceNow <span class="icon is-normal"><i class="is-normal ii ii-external-link"></i></span><span class="sr-only">(opens in an new tab)</span></a></li>';
// Add this tab after the 'Intranet' results tab
$('#directoryTabs li:nth-child(1)').after(servicenow);
}, 500);