Drupal Views Relationships and Arguments

≡放荡痞女 提交于 2019-12-24 10:58:31

问题


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)

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?

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...


回答1:


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. Skip views altogether and do a custom query.

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

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

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



来源:https://stackoverflow.com/questions/3718743/drupal-views-relationships-and-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!