- If the search & search result page has already been integrated into the shop, many required components are already in place, and only targeted adjustments are required for the category templates.
- If no WEBSALE search is used (e.g. because an external provider such as Findologic or FACT Finder is responsible for the search), the necessary components and scripts must be fully included for the category pages.
Scenario: search & search result page already integrated
Already existing components
If the search has already been implemented in the shop, the following components are already included in all templates and do not need to be integrated again:- WEBSALE JavaScript library
- JavaScript bundle (
ws-search-component-<version identifier>.js) - Communication component (
ws-search) - Search input field with optional suggest function (
ws-search-box) - Search event dispatcher & forwarding of search queries (
wsResultDispatcher.subscribe)
Adjustments for the category page (ws_category.htm)
For the category template ws_category.htm, only the following additional adjustments then need to be made:
- Inclusion of the
ws-search-resultcomponent - Template placeholder for the product box (
<template id="resultItemTemplate">) - Filtering of the category products via
ws-filter - Optional: include/exclude switch for individual filters via
ws-filter-toggle - JavaScript for rendering the filters
- Sorting of the category products via
ws-sort-box - Pagination / paging of the category products via
ws-pagination
Extension of the existing communication component
The<ws-search> component may only appear once in the template. Since it has already been included for the search & search result page, for the category page only the parameter category="" with a breadcrumb output without a separator needs to be added.
Scenario: no existing search integration
If the shop search runs via external providers such as Findologic or FACT Finder, the WEBSALE search is not integrated. In this case, for the filter and sort functions on category pages, all required components must be explicitly included for the category template (ws_category.htm).
The following guide describes the necessary adjustments to correctly integrate filtering and sorting via the WEBSALE search module.
Provision of the required resources
For the search module to work on the category page, the following resources must be included:WEBSALE JavaScript library
The WEBSALE JavaScript library provides all relevant JavaScript modules for the search module as well as other standard shop functions. There are two variants of the library:ws-system-<version identifier>.js- WEBSALE JavaScript modules including the jQuery library.ws-core-<version identifier>.js- WEBSALE JavaScript modules without jQuery. In this case, jQuery must be included separately.
If the WEBSALE JavaScript library is already included for other shop functions, it does not need to be integrated again.
JavaScript bundle
WEBSALE provides the JavaScript bundlews-search-component-<version identifier>.js. This is required for the functionality of the filter and sort components.
You can include the bundle via the WEBSALE PageSpeed tool or download it directly at:
Communication component
In addition to the JavaScript bundle, thews-search component is required. It is provided by WEBSALE and is used for the communication between the frontend, the backend, and the integrated WebComponents. This component may only appear once per template.
Inclusion of the search box component
For the filter and sort functions to be used correctly, thews-search-box component must be included technically - even if it is not actively used for the search.
Search event dispatcher for filter & sort
The following script ensures the correct rendering of the filter and sort functions and should be included in the<head> of the template.
- Detects when new search results or filter results are available.
- Loads the product boxes via AJAX.
- Enables a smooth filter and sort experience.
Integration of the products
The integration for the products on the category template must be adjusted as follows:Using the ws-search-result component
The<ws-search-result> component processes the data from the search module and displays the filtered products on the category page.
Template placeholder for the product box
To avoid height shifts when loading the product boxes, a<template> can be specified inside ws-search-result. This is displayed as soon as the product box is loaded.
To define the template for the placeholders, result-placeholder must be specified at the slot:
Template for the WEBSALE product box (incl_productbox.htm)
To reload the product box, an additional template must be created and stored in the shop’s template directory (default: translation template directory).
If the name of the template differs from incl_productbox.htm, the associated JavaScript script (see Search event dispatcher & forwarding of search queries) must be adjusted accordingly.
~WS-Fast_Include(Incl-ProductBoxCategory)~: This is the include area that loads the complete product box with all shop functions.
Incl-ProductBoxCategory usually comes from the file incl_fast_includes.htm, but can be named differently depending on the shop. Make sure to enter the correct include name. Inside the product box, the class wsProductBox-XX (replace XX with the product number) should be present so that these products, if already present, are not reloaded during sorting or filtering.Filtering the products
Before filters are available in the frontend, the product data fields that can be used for filtering must be defined in the configuration of the search module. This configuration defines which filter types (e.g. checkboxes, sliders) can be used for specific fields.Filter components
Example for the integration of the filter components:Include (eq) and Exclude (neq), the ws-filter-toggle component can additionally be included before the respective filter:
JavaScript for rendering the filters
As of
ws-search-component-1.9.1.js, this functionality is included natively in the WebComponents: filters are automatically set from the URL parameters and the category path when the page is loaded (see Automatic filter initialization). The following script is only required for older bundle versions.Sorting the products
The sorting is controlled via the<ws-sort-box> component:
