Skip to main content

Zoovu Search Plugin JavaScript API

The Zoovu Search Plugin provides a set of JavaScript methods that allow you to:

  • Trigger specific actions outside the plugin.
  • Dynamically update configuration settings.
  • Control search behavior programmatically.

Configuration

The changeConfig method updates a configuration setting after the plugin has been initialized.

Parameters

  • key (String) – The path to the setting in zoovuSearchConfig. Example: suggestions.show
  • value (*) – The new value to be set.
Examples:
  • Update the included result groups:
ZOOVU_SEARCH.changeConfig('contentGroups.include', ['Recipes']);
  • Update the entire contentGroups object:
ZOOVU_SEARCH.changeConfig('contentGroups', { include: ['Recipes'], exclude: undefined });

Update siteId

The setSiteId method updates the site ID after initialization.

Parameter:

  • siteId (String) – The new site ID.
Example:
ZOOVU_SEARCH.setSiteId('mySiteId.com');

Change base URL

The setBaseUrl method updates the URL used to load search results.

Parameter:

  • baseUrl (String) – The new search results URL.
Example:
ZOOVU_SEARCH.setBaseUrl('https://api.search-studio.zoovu.com/sites');

Change suggestion URL

The setSuggestUrl method updates the URL used to load search suggestions.

Parameter:

  • url (String) – The new search suggestions URL.
Example:
ZOOVU_SEARCH.setSuggestUrl('https://api.search-studio.zoovu.com/sites/suggest');

Controls

(Re)initialize

By default, the Zoovu Search Plugin initializes automatically when the page loads. If you create the search field dynamically or need to restart the plugin, call init().

Example:
ZOOVU_SEARCH.init();

Show search results

You can trigger a search manually using showResults(), instead of relying on the search field or button.

Parameters:

  • query (String) – The search query.
  • sort (String, optional) – Sorting option. Default: undefined.
  • pushState (Boolean, optional) – Whether to update the browser history. Default: true.
  • searchButton (Node, optional) – The button that triggered the search (for tracking).
  • callback (Function, optional) – A function to run after rendering the results.
Example:
ZOOVU_SEARCH.showResults('pizza');

Open a specific result group (tab)

By default, search results open in the "All results" tab. If you want to open a specific result group tab (e.g., "News"), use openTab().

Example:
ZOOVU_SEARCH.openTab('News');

This method only changes the active tab. It does not filter out other result groups.

Show fullscreen search layer

If using fullscreen search results, you can trigger the overlay manually using showFullscreenLayer().

Example:
ZOOVU_SEARCH.showFullscreenLayer();

Close search results

To hide search results, use closeLayer(). This only works for overlay or fullscreen layouts.

Example:
ZOOVU_SEARCH.closeLayer();

Hide search results

To hide search results regardless of layout type, use hideSearchResults().

Example:
ZOOVU_SEARCH.hideSearchResults();

Show or hide the loading animation

You can control the loading animation manually.

Show loading:
ZOOVU_SEARCH.showLoading();
Hide loading:
ZOOVU_SEARCH.hideLoading();

Helpers

Check if the plugin is initialized

The isInitialized() method checks whether the Zoovu Search Plugin was successfully initialized.

If it returns false, the search may still work, but there was an initialization error (e.g., the script was embedded multiple times).

Returns:

initialized (Boolean) – true if initialization was successful, false otherwise.

Example

var success = ZOOVU_SEARCH.isInitialized();