If you would like to add a hierarchical filter for date then add a tree view field to the Layer. For example I have three tagbox fields for Year/Month/Day in my Basic Information Layer and have added a Tree View field to display the date:
I have entered the below in Levels. The allow recursion will be set to false by default after saving.
The fields will be shown in the filter in the order below. For an American date for example you may want to use month/day/year.
[ { "fieldId": "year" }, { "fieldId": "month" }, { "fieldId": "day" } ]
Once this is done you need to add a Channel Filter:
Where you can also set a path in addition to the usual Channel Filter settings. For an explanation of paths see tbd.
This will then result in the Hierarchical Filter as pictured below:
If you would like the filter to display a month name such as October instead of 10 then you can add code to the Name Display pattern of the list that is linked to your Month tagbox in this example. You will need to adjust this for multiple languages if required, or to only filter for e.g those List Items that have Month in the broader field so that you are sure to get a correct display.
{% assign month_names = "January,February,March,April,May,June,July,August,September,October,November,December" | split: "," %} {% assign keyword_name = data.keyword.name | translate %} {% assign state = data.keyword.state.name["x-default"] %} {% assign is_number = keyword_name | plus: 0 %} {% if data.keyword.broader %} {% assign broader_tags = data.keyword.broader | tagbox_name %} {% if broader_tags contains "Month" %} {% if is_number >= 1 and is_number <= 12 %} {% assign counter = 0 %} {% for month in month_names %} {% assign counter = counter | plus: 1 %} {% if counter == is_number %} {% assign keyword_name = month %} {% endif %} {% endfor %} {% endif %} {% endif %} {% endif %} {{ keyword_name }} {% if state != 'Active' %} ¬{% endif %}
0 Comments