How To Configure the SearchBox
About SmartHub SearchBox
The SmartHub SearchBox module enables you to execute queries.
                                                
                                            
                                                
                                            
How to Configure the SmartHub SearchBox
UI Builder
- 
                                                    
The easiest and fastest way to insert and customize the SearchBox is via the SmartHub UI Builder.
 - 
                                                    
To configure the SearchBox component, you edit the Advanced Settings file that you are using for your SmartHub pages (procedure below).
 - 
                                                    
For more information about using Custom Settings, see How to Use the UI Builder.
 - You can override any setting by adding it to the 
SH.SearchBox.CustomSettingsnamespace. 
Procedure:
- 
                                                    
SmartHub administrators can simply click the UI Editor link from the SmartHub ADMINISTRATION page.
 - 
                                                    
Click the Select a page link from the top menu.
 - 
                                                    
Select (double-click) an HTML page such as Results.html page.
- 
                                                            
Below, the Results.html page is shown for sample purposes.
 - 
                                                            
BA Insight recommends you use page and folder to modify. Leave the default files as templates.
- 
                                                                    
Example: pages/CustomResults.html. Default Results.html is under the top most SmartHub directory.
 
 - 
                                                                    
 
 - 
                                                            
 - 
                                                    
Select the Advanced mode from the top right of the page.
 - 
                                                    
Select Advanced settings edit.
 - 
                                                    
Scroll down to line 301 (this may vary), which contains the text "
SH.SearchBox.CustomSettings"
                                                        
 - 
                                                    
Click the See Default Settings link at the top right.
 - 
                                                    
A new browser tab opens with all available SmartHub module settings.
 - 
                                                    
Scroll down (towards the bottom of the page) to the line that contains the text "
SH.SearchBox.DefaultSettings = {"
 - 
                                                    
Copy the settings under settings after the text "SH.SearchBox.DefaultSettings = {".
 - 
                                                    
Go back to your Advanced settings edit tab.
 - 
                                                    
Paste the copied settings inside the section "SH.SearchBox.CustomSettings = {".
 - 
                                                    
Modify the settings as desired. See the table SearchBox Settings below for more information.
 - 
                                                    
Note the Template files referenced:
- 
                                                            
searchboxTemplate.html
 - 
                                                            
scopedSearchTemplate.html
 - 
                                                            
keepRefinersTemplate.html
 
 - 
                                                            
 - 
                                                    
These templates can be modified. They are located in the directory:
- 
                                                            
<SmartHub-install-dir>\modules\SearchBox\templates
 
 - 
                                                            
 - 
                                                    
Click the link "Preview <file>.html" at the top of the page.
 - 
                                                    
Return to the previous page and make changes, if necessary. Repeat Step 15 until the desired results are achieved.
 - 
                                                    
Click Save changes.
 
Example Configuration
SH.SearchBox = SH.SearchBox || {};
SH.SearchBox.DefaultSettings = {
    ".sh-search-section": {
        Enabled: true,
        SearchBoxTemplatePath: SH.RootLevelURL + "/modules/SearchBox/templates/searchboxTemplate.html",
        ScopedSearchTemplatePath: SH.RootLevelURL + "/modules/SearchBox/templates/scopedSearchTemplate.html",
        KeepRefinersTemplatePath: SH.RootLevelURL + "/modules/SearchBox/templates/keepRefinersTemplate.html",
        ShowScopedSearch: true,
        ShowKeepRefiners: true,
        RemoveResultsOnClear: true,
        ShowSelectedScope: false,
        EnableDuplicateSearch: true,
        ModuleDetails: {
            SearchBoxPlaceholder: "Search...".toLocaleString(),
            KeepRefinersLabel: "Keep Refiners".toLocaleString()
        }
    },
    ".search-within": {
        Enabled: false,
        SearchWithin: true,
        SearchBoxTemplatePath: SH.RootLevelURL + "/modules/SearchBox/templates/searchboxTemplate.html",
        ModuleDetails: {
            SearchBoxPlaceholder: "Search within...".toLocaleString(),
            KeepRefinersLabel: "Keep Refiners".toLocaleString()
        }
    }
}
                                                    Note: Make sure that an element with the identifier specified in the SearchBoxParentSelector setting exists on your page;
- 
                                                        
The SearchBoxParentSelector is also the key used to identify the SearchBox.
 - 
                                                        
The out-of-the-box value for the SmartHub SearchBox is ".sh-search-section".
 
SH.SearchBox.CustomSettings = {    
        ".sh-search-section":{
            Enabled: true,
            SearchBoxTemplatePath: SH.RootLevelURL + "/modules/SearchBox/templates/searchboxTemplate.html",
            ScopedSearchTemplatePath: SH.RootLevelURL + "/modules/SearchBox/templates/scopedSearchTemplate.html",
            KeepRefinersTemplatePath: SH.RootLevelURL + "/modules/SearchBox/templates/keepRefinersTemplate.html",
            ShowScopedSearch:true,
            ShowKeepRefiners:true,
            RemoveResultsOnClear:true,
            ShowSelectedScope:false,
            EnableDuplicateSearch:true,
            ModuleDetails: {
                SearchBoxPlaceholder: "Search...".toLocaleString(),
                KeepRefinersLabel: "Keep Refiners".toLocaleString()
            }
        }
            
    } 
                                                    SearchBox Settings
The SearchBox parameters and their values are listed below.
| 
                                                             Setting  | 
                                                        
                                                             Value  | 
                                                        
                                                             Description  | 
                                                    
|---|---|---|
| Enabled | 
                                                             Boolean Default: false  | 
                                                        If this is set to "false", the component does not make any changes to SmartHub and does not load any dependency. | 
| 
                                                             SearchBoxTemplatePath  | 
                                                        
                                                             string Default: SH.RootLevelURL + "/modules/SearchBox/templates/searchboxTemplate.html"  | 
                                                        The path to the template used for the SearchBox | 
| 
                                                             ScopedSearchTemplatePath  | 
                                                        
                                                             string Default: SH.RootLevelURL + "/modules/SearchBox/templates/scopedSearchTemplate.html"  | 
                                                        The path to the template used for the ScopedSearch verticals | 
| 
                                                             KeepRefinersTemplatePath  | 
                                                        
                                                             string Default: SH.RootLevelURL + "/modules/SearchBox/templates/keepRefinersTemplate.html"  | 
                                                        The path to the template used for the KeepRefiners toggle | 
| 
                                                             ShowScopedSearch  | 
                                                        
                                                             Boolean Default: true  | 
                                                        Enables you to show/hide the ScopedSearch selector | 
| 
                                                             ShowKeepRefiners  | 
                                                        
                                                             Boolean Default: true  | 
                                                        
                                                             Enables you to show/hide the KeepRefiners toggle. If there are no refiners on the page, the KeepRefiners toggle will be automatically disabled.  | 
                                                    
| 
                                                             RemoveResultsOnClear  | 
                                                        
                                                             Boolean Default: true  | 
                                                        Enables you to clear the results when you remove the text from the SearchBox | 
| 
                                                             ShowSelectedScope  | 
                                                        
                                                             Boolean Default: false  | 
                                                        Enables you to show/ hide the name of the selected scope | 
| 
                                                             EnableDuplicateSearch  | 
                                                        
                                                             Boolean Default: true  | 
                                                        Enables you to execute multiple queries for the same query text | 
| 
                                                             ModuleDetails  | 
                                                        
                                                             Object Default: {  | 
                                                        
                                                             Contains the labels used in the SearchBox component  | 
                                                    
The SearchBox has a special container that should be used as a container when showing different components that need to be next to the SearchBox.
That container has the class ".searchbox-widgets" and it should be targeted via the SearchBoxParentSelector.
Example:
".sh-search-section .searchbox-widgets"
Example showing the personalization link:
Exposed Functions and Available Events
Available Events
| Event name | Trigger | Data | 
|---|---|---|
| 
                                                             SearchboxAdded  | 
                                                        Triggered when the SearchBox is created | 
                                                             {SearchBoxKey: key}  | 
                                                    
