Getting data from other nodes within a Drupal View
I have a View in Drupal (6) which I'm using to build a page for viewing the contents of a node.
A set of开发者_StackOverflow社区 n other nodes (of a different type) have content that is related/applicable to this node, and I would like to take their data and print it out in the view too.I could easily get these nodes programmatically via load_node()
so long as I have the current NID accessible. I tried this first - using a Global: Virtual Formatted Field
in my view. Unfortunately - the variables that are meant to be accessible within this field are all empty. I don't know why this is - as it's the last field in my view, but the result is I can't do anything with it.
I have also tried experimenting with view relationships, but I'm quite new to that and I'm not even sure it's possible to do what I'm trying to using it.
Does anyone have any idea on how I could achieve this?
Thanks
I found this tutorial helpful for learning about relationships and I could achieve something similar to what you are trying.
Assume u have 2 content type X and Y. You have a node reference of Y in X. Now you are creating a view of X and want to load information of Y into the X view. So you can use relationships in views. 1 - Create a filter of node type X. 2 - In the relationship select the node reference field to Y present in X. 3 - Now in the fields you can select both X and Y fields. But if you select Y fields there is a select in that field about relationship like (is relationship required) here you can select the relationship created in step 2.
精彩评论