简体   繁体   English

Drupal以分类学术语加入

[英]Drupal join on taxonomy terms

I have a Drupal setup like this: 我有这样的Drupal设置:

  • Content type: Apartments 内容类型: 公寓
  • Vocabulary: Areas , that can be used with Apartments. 词汇:可以与Apartments一起使用的Areas
  • Content type: User profile , with a Content Taxonomy Field for Areas so users can select what areas they are interested in. 内容类型: 用户个人资料 ,具有“区域”的“内容分类”字段,因此用户可以选择他们感兴趣的区域。

I would like a view that shows all the user profiles that matches the apartments in their area. 我想要一个显示所有与其所在地区的公寓相匹配的用户资料的视图。 A "User profile <-> Areas <-> Apartments" join in other words. 换句话说,“用户配置文件<->区域<->公寓”加入。 I've been mucking around with the views interface for a while but it's not clear to me how the relations can be setup to achieve this. 我已经在一段时间内与视图界面混为一谈了,但是我不清楚如何建立关系来实现这一点。 Can someone give me a hint? 有人可以给我提示吗?

In case this cannot be easily solved with views, what is a good way of doing it otherwise? 如果无法通过视图轻松解决此问题,否则有什么好的方法呢? Thanks for your help. 谢谢你的帮助。

In my experience I've found that views doesn't do taxonomy very well. 根据我的经验,我发现视图不能很好地进行分类。 It's often quite hard to get what you want and then you sometime strugle with duplicates. 通常很难获得想要的东西,然后有时会遇到重复的问题。 Often I've found myself hitting a dead end using views for this. 我经常发现自己为此使用视图陷入困境。

In this case I would probably do this in a custom module. 在这种情况下,我可能会在自定义模块中执行此操作。 You don't have to do much. 您不必做很多事情。 You should be able to make a simple query where you get all apartment nodes that has the same tid as the user profile. 您应该能够进行简单的查询,从而获得所有tid与用户配置文件相同的单元节点。 Then it's just a matter of what info you want to pull out. 然后,这只是您要提取的信息的问题。 You should avoid making node_load() as it'll slow the page down a lot. 您应该避免使用node_load(),因为它会大大降低页面速度。

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

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