Search Page in Sitecore SXA


                             

There are three parts of this page :

1. Search Box
2. Search Results 
3. Filters


1. Set up Search Box :

To enable your visitors to search your site, you can add a search box to your pages. By default, the Search Box rendering adds the search text box to the page. You can customize the search box by configuring the item and changing the properties.

To add a search box to your page:

  1. From the Toolbox, drag the Search Box rendering to the page.
  2. In the Select the Associated Content dialog box, for the search box, select the Default item.
3. In the Select the Associated Content dialog box, for the search box, select the Default item.

Search results signature – enter the unique signature of a specific Search Results rendering to limit the search results. This can be convenient when you have more than one search result rendering on the page.Search scope – select a scope to limit the search results. Target signature – if you created a separate search results page, enter the signature of that page here.

Max predictive results count – sets the maximum number of predictive results shown in the drop down. When you leave this field empty, no predictions are shown.

Search results page – select the specific search page, if you want to direct to a separate page.

Show search textbox – selected by default. Clear to remove the search text box.

Suggestions mode – select an option from the drop-down box.

2. Set up Search Results:

For users to view the results of their search, you must add the Search Results rendering on the page. For simple solutions, you can have the search results appear on the same page.

To add the Search Results rendering:

  1. To change the Search Results rendering parameters, for example, to determine how many results should be loaded at once, or how the results are sorted, in the Select the Associated Content dialog box, select the Default item.

  2. In the Control Properties dialog box, edit the following fields to specify how to arrange the search results:

    • Search results signature – enter the unique signature of a specific Search Results rendering to limit the search results. This can be convenient when you have more than one search result rendering on the page and you only want to filter on specific search results. When you leave this field empty, it will filter all Search Results renderings with no signature.

    • Search scope – select a scope to limit the search results.

    • Page size – enter the number of results you want to be loaded by the rendering.

    • Default language filtering – select the language you want to use for the search.

    • Default sort order – select the way the results are sorted on the page. This is only used when the Sort Results rendering is not used.

    • Automatically fire search when no criteria set - when selected search will not be triggered until the users provides search criteria.


  3.  Setup Filters
        SXA comes with several filter components to allow website visitors to narrow their search         results. This topic describes how to work with the different filters.

We will use Filter(Dropdown) rendering : 

The Filter (Dropdown) filter filters search results based on items that are tagged with a selected facet.

To add a Filter (Dropdown) component:

  1. From the Toolbox, drag the filter to the page, and in the Filter (Dropdown) toolbar, click the cogwheel to set the facet that you want to filter on.

  2. You can edit the following fields:

                              3. On the Filter (Dropdown) toolbar, click More, and click Edit Component                                 Properties and specify the Sort order for the filter in the FilterCriteria section.



Facets


Our filter is still empty now. The pages in SXA have tagging by default and we did tag all of them with one or more tag values. So lets try to filter on those tags!

First we create a facet "Tag".
In the facet item we set the name and display name and the field name. This is the lower case name of the field that is used in the index and that the facet is based on, in our case it's "sxatags". If you don't know the exact name of the fields you can always find this by looking at the templates used by the (SXA) items.

Once we have the facet item, we create a datasource for our Filter component and set the Facet field to the one we just created. Et voila, we publish and see:

facets with numbers in the dropdown filter box. By selecting one of them, the search results get filtered on the tag. 


Comments

  1. What should be the value of the Search Results Signature in both Search Box & Search Results Rendering.?

    ReplyDelete

Post a Comment

Popular posts from this blog

Custom Dropdown in Sitecore form

How to use snippets in SXA project