Category Pages
This Site Search 360 demo shows how a shop's category pages can each have their own filters. Use the buttons in the demo to switch between two category pages and a normal search, and watch the filters change: Dairy & Eggs filters by brand, fat and price, Sweets & Snacks by availability and calories, and a search shows the usual category, price and rating. View the ss360Config to check the configuration.
- A category page shows the filters set up for its category under Navigational Query Filters. A normal search keeps your global filters.
results.categorySearchmakes a page a category page.urlPatternreads the category from the page URL: the buttons open this page with?cat=Dairy%20%26%20Eggsor?cat=Sweets%20%26%20Snacks.queryPathSeparatorsplits a path such asBooks/Historyinto its categories.replacementPatternsturns the URL encoding back into the category name, soDairy%20%26%20EggsbecomesDairy & Eggs.ignoredQueryParamsstopscatfrom also being read as a filter.- The category names must match the names in your product feed. Other ways to read the category, for example from the breadcrumb, are listed under
categorySearchin Advanced Parameters.
In the Control Panel: set up the filters of each category under Filters and Sorting → Navigational Query Filters, then add categorySearch under Design & Publish → Advanced → Configuration → Plugin Configuration.
For filters in a normal search, see the Filters demo.
window.ss360Config = {
siteId: '83460', /* Replace with your site id */
searchBox: {
selector: '#searchBox' /* Replace with the css selector of your search box */
},
results: {
embedConfig: {
contentBlock: '.example__page-content-block' /* Replace with the css selector of the element the results go into */
},
categorySearch: {
urlPattern: '[?&]cat=([^&]+)', /* Replace with the pattern of your category page URLs */
queryPathSeparator: '/',
replacementPatterns: {
'%20': ' ',
'%26': '&'
},
ignoredQueryParams: ['cat']
}
},
contentGroups: {
include: ['Grocery Products']
},
filters: {
enabled: true,
position: 'left'
}
};
{"siteId":"83460","searchBox":{"selector":"#searchBox"},"results":{"embedConfig":{"contentBlock":".example__page-content-block"},"categorySearch":{"urlPattern":"[?&]cat=([^&]+)","queryPathSeparator":"/","replacementPatterns":{"%20":" ","%26":"&"},"ignoredQueryParams":["cat"]}},"contentGroups":{"include":["Grocery Products"]},"filters":{"enabled":true,"position":"left"}}