How to pass arguments between views in Drupal-7
I consistently find myself up against the following use case, and have yet to grok the proper workflow / solution:
I would like to display two views.
In the first view, each row displays one node of type-x.
The second view shows nodes of type-y, which are associated with node type-x via a nodereference, as follows:
View-1 View-2
------ ------
row1 X-a <---> Y-a
row2 X-b <---> Y-b
row3 X-c <---> Y-c
row4 etc <---> etc
For example, X is an event, and Y is a venue. Or, X is a porfolio page, and Y is a paged gallery.
I understand that there are other ways of approaching this - for example using node views rather than fields, but I am trying to leverage views to create 2 distinct custom queries related by an argument passed from one view to the other.
This is a variation of a question I asked earlier (Programmatic Views in Drupal 7), and hopefully a clarification.
Any help, even (or especially) just on the semantic level, is gr开发者_如何转开发eatly appreciated.
You should use the EVA module. It does what you need in an elegant way.
https://drupal.stackexchange.com/questions/5732/is-there-a-good-tutorial-for-entity-views-attach-module
Hm I am not sure if I understand it correctly, but I think what you want to do is pass an argument to the view and then filter the results by it.
The option to configure the parameters in the UI is called 'Contextual Filters'.
Then you can call the view from your code like this(suppose your parameter is a node id):
<?php
print views_embed_view('example_view', 'page', $node->nid);
?>
If I understand, I think the best way would be to use only one view, and set a relationship on the node reference. Then create a field for the field you are displaying from the first node, and a field for the second node.
精彩评论