Coveo for Sitecore Legacy Search UI Framework jQuery Plugin
Coveo for Sitecore Legacy Search UI Framework jQuery Plugin
Coveo for Sitecore 4.1 (November 2018)
This help page only applies to the Legacy UI. The jQuery plugin doesn’t exist within the Coveo for Sitecore Hive Framework.
The JavaScript code used to enable searching with Coveo for Sitecore is wrapped in the coveoForSitecore
jQuery plugin. It’s defined in the CoveoForSitecore.js
file. So far, the only available action is init
, which initializes the search interface. In the background, it calls the coveo
plugin of the JavaScript Search Framework.
jQuery Plugin Usage
Here is how the plugin is used by the search component.
<script type="text/javascript">
Coveo.$(function() {
var options = <%= Model.GetJavaScriptInitializationOptions() %>;
Coveo.$('#search').coveoForSitecore('init', options);
});
</script>
The call to Model.GetJavaScriptInitializationOptions()
builds a JavaScript object holding all settings that are required to initialize the search interface. You can alter the options object to override the values it contains. Doing so allows you to modify how the various components are initialized.
Available Options
The table below describes the options that are available when calling the coveoForSitecore
plugin with the init
action. Those options are filled automatically from the properties that are set on the search component. You should set the appropriate values on component properties using Sitecore when possible. But sometimes, you may want to manipulate the options directly using JavaScript.
Option | Description |
---|---|
analyticsEndpointUri |
The URI of the REST endpoint used to report analytics events. |
boostExpressions |
The expressions that are computed by the ‘Boost Expressions’ field of the search component. |
clientLanguageFieldName |
Contains the name of the field that holds the language of an item. |
clientLanguageName |
The current language. |
componentRefreshCallback |
Defines the callback function that has to be called to refresh a component. This is used when editing components in the Page Editor. The default callback method is defined in the PageEditorDeferRefresh.js file. |
enableClientSideLogging |
Whether client-side logging should be enabled. |
externalSources |
Array containing the names of the external sources to include in the search query. |
filterResultOnLatestVersion |
Whether results only contain the latest version of each item. |
filterResultsOnCurrentCulture |
Whether only results that match the current culture are returned. |
hiddenExpression |
The expression that’s computed by the ‘Filter Expression’ field of the search component. |
indexSourceName |
Contains the index source name given by the Search Provider for the current database. |
isEditingInPageEditor |
Whether the search interface is opened in edit mode on the Sitecore Page Editor. |
isInitialized |
Whether the search interface has been initialized. This is used when editing Coveo components with the Sitecore Page Editor, preventing the search interface from loading more than once. |
isPreviewingInPageEditor |
Whether the search interface is opened in preview mode on the Sitecore Page Editor. |
isPreviewingInPageEditorWithSimulatedDevice |
Whether the search interface is opened in a device simulator on the Sitecore Page Editor. |
latestVersionFieldName |
Contains the name of the field that indicates if an item is the latest version of the corresponding item. |
restEndpointUri |
The URI of the REST endpoint used to perform search queries. |
resultListInfiniteScrollContainer |
Defines the container that holds the results list. This is used when the ‘Enable Infinite Scrolling’ option is enabled on the search component. |
sitecoreItemId |
Contains the ID of the current Sitecore item. This is used when reporting analytics events. |
Adding Your Custom Client Code
The JavaScript Search Framework is flexible when it comes to customizing the behavior of a search interface. Here are some examples to help you get started.