Build a Search Page
Build your search page from separate components when you want control over the layout, for example the Search Bar, the filters and the results side by side, with image search on the same page. The components connect through events, so you place them on the page and they work together.
To keep the Search Bar on other pages too and send shoppers here when they search, see Redirect Search to a Results Page.
Before You Start
Section titled “Before You Start”You need:
vviinn-widgets2.76.1 or later, preferably the latest version (see Install the Widgets)- the read-only token (see Authentication)
- an active Text Search campaign, plus a Visual Search campaign if shoppers search by image (see Campaigns)
Add the Components
Section titled “Add the Components”-
Add the Search Bar,
vviinn-text-search. Setmode="extended"to offer image search next to the text input. -
Add the Product List,
vviinn-results, where the results appear.results-countsets how many results it fetches, up to the maximum set in the campaign. -
Add the filters:
vviinn-filtersfor the primary filters in a compact bar,vviinn-extended-filtersfor all filters, andvviinn-selected-filtersfor the values the shopper has chosen. -
Add the Cropper,
vviinn-cropper, to show the uploaded image after an image search and let shoppers change the search area.
Every component except the filters takes the read-only token in token. The other attributes are on each component’s page.
The example puts all of them on one page: the Cropper and the full filter list in a sidebar, and the Search Bar, the filters and the results in the main column. On small screens the sidebar is hidden and the filters move above the results. --product-card-width sets the card width (see CSS Variables).
Choose the Filter Columns
Section titled “Choose the Filter Columns”The filters show the columns the Text Search campaign offers as filters. In Panel, under Campaigns, open the Text Search campaign, then under Interface Controls select Filters. Columns marked Primary appear in vviinn-filters, and every column turned on appears in vviinn-extended-filters. The campaign settings are described on Text Search.
Check That It Works
Section titled “Check That It Works”On your search page:
- Search for a product you know is in your catalog. Results appear in the Product List.
- Select a filter value. The results narrow, and the value appears in
vviinn-selected-filters. - With
mode="extended", upload a photo. The Cropper shows it, and the results change when you move the search area.
Related
Section titled “Related”Next pieces to add:
- Redirect Search to a Results Page: put the Search Bar on every page and send searches here
- Build a Product List Page: the same layout without a Search Bar
- Events: the events the components emit, for analytics and custom code
- Troubleshooting: Widgets: empty filters, fewer results than expected, and other problems