简体   繁体   English

日期的Drupal 8上下文过滤器

[英]Drupal 8 contextual filter for date

does anybody know how to implement the view with contextual filter on date/time value? 有谁知道如何用日期/时间值的上下文过滤器实现视图? I have a content type Event with date field within it and need to somehow filter items within specific month. 我有一个带有日期字段的内容类型事件 ,并且需要以某种方式过滤特定月份内的项目。 Not sure if it can even be done without special programming and if so, whether via that contextual filter (like node/) or maybe via exposed filter with list of months so user can filter items by himself?? 不确定是否无需特殊编程就可以完成,如果可以,是否通过该上下文过滤器(例如node /),还是通过带有月份列表的公开过滤器,以便用户自己过滤项目?

Thanks TC 谢谢TC

There exists the contextual range filter module. 存在上下文范围过滤器模块。 https://www.drupal.org/project/contextual_range_filter 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. 到目前为止,我写的模块页面上没有显示Drupal 8版本,但是有一些。 Have a look in the release section "View all releases". 在发布部分“查看所有发布”中查看。 There you can filter the API version "8.x". 在此可以过滤API版本“ 8.x”。

You can have a look into the README.txt for all the possibilities to query. 您可以查看README.txt,查询所有可能的方式。 http://cgit.drupalcode.org/contextual_range_filter/plain/README.txt?id=refs/heads/8.x-1.x 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 创建日期

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM