Configure Human-Readable Date Facets
Introduction
Goal
Configure human-readable date facets in a faceted tree.
Background
When using a date property as a facet in a faceted navigation, facet values will show as milliseconds since epoch by default. To make date facets understandable for human beings, it is possible to configure date resolutions such as year, month, and day.
Date Resolutions
To specify a resolution for a date facet, add a dollar sign ($) and the desired resolution after the property name in hippofacnav:facets. For example:
myhippoproject:date$year
The following date resolutions are available:
-
year
-
month
-
week
-
dayofyear
-
dayofweek
-
day ( = day of month)
-
hour
-
minute
-
second
Example
To enable navigation of news documents (from the out-of-the-box News feature) by publication date, configure a faceted tree as follows:
/content/documents/myhippoproject: /faceted-news: jcr:primaryType: hippofacnav:facetnavigation hippo:docbase: d2b1775c-fb97-4080-bd66-ede4ac874b5a hippofacnav:facets: [ myhippoproject:date$year, myhippoproject:date$month, myhippoproject:date$day ] hippofacnav:facetnodenames: [ Year, Month, Day ]
The result is a faceted tree as in the example below:
/content/documents/myhippoproject: /faceted-news [30]: /Year [27]: /2015 [1]: /2016 [18]: /Year [18]: /Month [18]: /6 [3]: /8 [9]: /Year [9]: /Month [9]: /Day [9]: /12 [3]: /17 [3]: /23 [3]: /hippo:resultset [9]: /hippo:resultset [9]: /9 [6]: /hippo:resultset [18]: /Day [18]: /hippo:resultset [18]: /2017 [6]: /hippo:resultset [27]: /Month [27]: /Day [27]: /hippo:resultset [30]:
Using such a faceted tree, a delivery tier implementation can render a faceted navigation which enables users to narrow their search results down by year, month, and day of the month. It is even possible to render the navigation as a calendar (see Events in the online GoGreen demo for an example).