简体   繁体   English

在Drupal 7中使用分类标准日期字段作为过滤器以进行查看

[英]Using Taxonomy Date Field as filter for view in Drupal 7

I have a taxonomy term 'Round' to which I've added a date field that corresponds with the Sunday of each week in the list. 我有一个分类术语“ Round”,在其中添加了一个与列表中每周的星期日对应的日期字段。 I use this term in a content type for football matches which occur on Weekends. 我在周末发生的足球比赛的内容类型中使用此术语。 This allows me to add a number of football matches for any week listed in the taxonomy vocab. 这使我可以为分类标准词汇中列出的任何一周添加一些足球比赛。

For example, round 1 (term) is Sunday, 1st May (date field). 例如,第1轮(学期)是5月1日(星期日)(日期字段)。 So I add 4 football matches, choosing round 1 as the term for each. 因此,我添加了4场足球比赛,每场比赛都选择了第一轮。 I don't have to add the same date for each match because it's already specified as a field in the taxonomy. 我不必为每个匹配项添加相同的日期,因为它已经被指定为分类法中的一个字段。

I'm creating a view to show the football matches for the upcoming weekend. 我正在创建一个视图以显示即将到来的周末的足球比赛。 The view has to display which round it is, the teams that are playing, and the date that it's being played. 该视图必须显示其所在的回合,正在参加的团队以及正在播放的日期。 I've got it doing that fine, but it also has to filter on the date field in the taxonomy so that it only shows the upcoming round of matches, ignoring those matches which are in the past. 我已经做到了这一点,但它还必须过滤分类法中的日期字段,以便仅显示即将到来的比赛,而忽略过去的比赛。

That's where I'm struggling. 那就是我在努力的地方。 I've created a Taxonomy Terms on Node relationship, specifying the Rounds vocab. 我创建了关于节点关系的分类术语,指定了回合词汇。 This allows me to select the date field as a filter, but it doesn't treat it as a date type (just treats it as a term/string), so I can't filter based on date. 这使我可以选择日期字段作为过滤器,但不会将其视为日期类型(只是将其视为术语/字符串),因此无法基于日期进行过滤。

How can I achieve this? 我该如何实现?

Finally found the answer to this, and it was an oversight on my part. 终于找到了答案,这是我的疏忽。 I hadn't enabled the views_date module, so although the view was recognising that it was a date for display purposes, it wasn't recognising it as a date for filtering purposes. 我尚未启用views_date模块,因此尽管视图已将其识别为用于显示目的的日期,但并未将其识别为用于过滤目的的日期。 Enabling that fixed the issue. 启用该功能可以解决此问题。

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

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