Replace the Default SharePoint Search Box with a SmartHub Search Box with Type-Ahead
About
This feature:
-
Integrates the SmartHub Search box into SharePoint Modern pages:
-
All searches are redirected to your SmartHub site
-
-
Integrates TypeAhead functionality into SharePoint Modern pages
How to Set Up SmartHub Search Box with SharePoint Modern Pages
Back up the configuration file
-
Navigate to the directory where SmartHub is installed.
-
Open web.config and remove the
X-Frame-Options
andContent-Security-Policy
headers. -
From /integrations/searchBoxForModernSPO copy the following file:
-
SHSearchboxModernCustomSettingsTemplate.js
-
-
Paste the file to the directory where you keep your customizations.
-
For example: <SmartHubInstallDirectory>/customer/SHSearchboxModernIntegration
-
Any settings related to the search box will be done in this file
-
Save the location where you copied this file.
-
Set up the Login.aspx page
-
Copy the Login.aspx file from the SmartHub installation directory to your customizations folder.
-
Edit your copy of Login.aspx page and replace all script src with your full SmartHub address.
-
For example:
-
<script src="https://contoso.smarthub.com/modules/SmartHubResourceLoader/lib/jquery.js"></script>
-
Delete all the characters in the first line at the top of the Login.aspx file between <% and %>.
-
Upload the custom Login.aspx file to your SharePoint asset library.
-
Make sure the URL to the Login.aspx resembles this format and structure:
https://contoso.sharepoint.com/mysite/Login.aspx
-
-
Edit your copy of SHSearchboxModernCustomSettingsTemplate.js
-
Replace "data-login-redirect-uri": "/SPOSite/LoginForSPO.aspx" with the path to your custom Login.aspx page.
-
Example: "/mysite/Login.aspx"
-
-
Replace "data-redirect-uri": SH.SmartHubAddress + "/Results.html" with the path of the page where you want clicking on suggestions to redirect to.
Note: Leave as is if you want to use the default Smart Hub address.
-
-
Go to your Azure Portal and add select the app registration that you used for SmartHub
-
Register the address of the custom Login.aspx page as a Redirect URI.
-
Example: https://contoso.sharepoint.com/mysite/Login.aspx
-
-
More information can be found in the Redirect URIs section of this page: Azure Active Directory Authentication.
-
-
Go to SmartHub Admin → Security
-
Add the SharePoint online domain in the Trusted Apps box. This is required to enable CORS.
-
Example: https://contoso.sharepoint.com
Use the SmartHub Application Loader for Modern SharePoint Online
-
You will be using the SmartHub Application Loader app to inject the "/integrations/searchBoxForModernSPO/SHSearchBoxModernLoader.js" file into SharePoint Online
-
Follow the steps here on how to install and configure: How to Install and Configure the SmartHub Application Loader for Modern SPO