問題描述
日期的 Drupal 8 上下文過濾器 (Drupal 8 contextual filter for date)
有人知道如何在日期/時間值上使用上下文過濾器來實現視圖嗎?我有一個包含日期字段的內容類型 Event,需要以某種方式過濾特定月份內的項目。不確定是否可以在沒有特殊編程的情況下完成,如果可以的話,是通過上下文過濾器(如 node/)還是通過帶有月份列表的暴露過濾器,以便用戶自己過濾項目?
感謝TC
參考解法
方法 1:
There exists the contextual range filter module. https://www.drupal.org/project/contextual_range_filter
To the time I am writing no Drupal 8 version is shown on the module page, but there are some. Have a look in the release section "View all releases". There you can filter the API version "8.x".
You can have a look into the README.txt for all the possibilities to query. http://cgit.drupalcode.org/contextual_range_filter/plain/README.txt?id=refs/heads/8.x‑1.x
A simpler solution could be to use the build in function in views You can add special fields in the contextual filters section They are called:
- Created year
- Created year + month
- Created week
- Created month
- Created day
- Created date
(by Tomáš Cigánek、sreher)