Drupal视图关系和参数 [英] Drupal Views Relationships and Arguments

查看:110
本文介绍了Drupal视图关系和参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Person内容类型。它具有公司的节点引用字段,该字段也是内容类型。然后,我有一个名为Project的内容类型。项目具有对公司内容类型的节点引用。我想列出所有与个人ID(nid)相关的项目。

I have a Person content type. It has a node reference field of a company which is also a content type. I then have a content type called Project. A project has a node reference to a company content type. I want to list all the projects related to a person id (nid)

如果我从视图和Drupal中抽象出来,并且每种内容类型都有它自己的表,我会使用

If I abstract this away from views and Drupal and each content type had it's own table I would use something like.

Select ProjectName from Projects where CompanyID IN (select CompanyID from Perons where PersonID = 10)

我可以在视图中做类似的事情吗?

Can I do something similar in Views?

我的PersonID是一个争论。
这将带回人员内容类型。然后,我将使用一种关系来带回公司。

My PersonID would be an argument. This would bring back the person content type. I would then use a relationship to bring back the company.

我现在不知道如何将公司与项目联系起来...

I now don't know know how to link the company up to the project...

推荐答案

这可能不是您要寻找的答案,但是我通常会为双重关系做两件事之一。

It may not be the answer you are looking for, but I typically will do one of two things for the double relationship thing.


  1. 完全跳过视图并执行自定义查询。

  1. Skip views altogether and do a custom query.

为第一个关系创建视图。在视图模板的内部,我将

Create a view for the first relationship. Inside the view templates for this, I will

2a。只需执行node_load()即可拉入节点以建立第二种关系。

2a. Just do a node_load() to pull in the nodes for second relationship.

2b。手动实例化传入正确参数的另一个视图(通过views_embed_view()或views_get_view_result())。

2b. Manually instantiate another view (either via views_embed_view() or views_get_view_result()) passing in the proper argument.

这篇关于Drupal视图关系和参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆