简体   繁体   English

Drupal 7:按分类/用户关系过滤视图

[英]Drupal 7 : View filtered with taxonomy / user relation

I have a view "news" which is listing nodes from "news" content type. 我有一个“新闻”视图,该视图列出了“新闻”内容类型的节点。 This content type contains a field "countries" which is multiple. 此内容类型包含多个字段“国家”。

So, my news "Test 1" will have a field countries like this one : France, United Kingdom, Spain 因此,我的新闻“测试1”将有一个像这样的领域国家:法国,​​英国,西班牙

My users have a field "Country". 我的用户有一个“国家”字段。

What I want to do is to add a filter criteria in my view meaning : News.countries = Users.country 我想做的是在我的视图中添加一个过滤条件,即:News.countries = Users.country

At this moment, when I try to do it, I cannot set a "must be equal to" to News.countries, certainly because it is multiple. 目前,当我尝试执行此操作时,我无法为News.countries设置“必须等于”,这肯定是因为它是多个。

Can you explain to me how should i do ? 你能告诉我怎么办吗?

You should use a contextual filter. 您应该使用上下文过滤器。 Add a relation to current logged in users country and add a contextual filter for the field new.country and use the relationship. 添加与当前已登录用户国家/地区的关系,并为字段new.country添加上下文过滤器并使用该关系。

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

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