Sitecore SXA Date Filter Use Cases

Date Filter is one of Sitecore SXA search filter components. It allows user to narrow search results by item date field. Here are use cases I put together to use this single component without creating additional custom date filter.

The SXA Date Filter takes From and To date as inputs

User Cases:

A – One date field: For example, news normally has only one date field.

Create a facet item based on news date field, then all above 3 use cases can be achieved by regular setting of date filer.

Facet item setting
Date Filer setting

B – Two date fields: For example, Event has start and end date. We need to search all events which active period overlapping a certain date range.

1, Event Start date is less than From-Date and End date is between From-Date and To-Date

2, Event date period covers From-Date and To-Date range

3, Event Start date is between From-Date and To-Date and End date is greater than To-Date

4, Event start and end date are between From-Date and To-Date

The Date Filter has From and To input boxes, but it can’t accommodate above scenarios as it takes only one date facet. How to achieve above 4 use cases with 2 date facets, the trick is, using combination of 2 Date Filters to query Events as 4 use cases all meet following criteria:

end date > From-Date and start date < To-Date

First date filter: Select EventEndDate facet and hide To-Date box.

Second date filter: Select EventStartDate facet and hide From-Date box.

After above setting, we will get date filters like below. It narrows down search results to all the active events between From and To date.

This entry was posted in Sitecore, SXA and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s