简体   繁体   中英

Drupal Views Relationships and Arguments

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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