I'm looking for a way to pass one View result to another (dependant) view for futher filtering.
I have Page view with exposed filters (view 1). Users by using exposed filters get some result set shown in a table. What I want to do is to add a block view, which will show nodes from a result set on a map. So the user will get results listed in a table and showed on a map.
The main idea is to get node_ids from a result set of View 1 and pass them as arguments to View 2, but I'm not sure how to achieve this.
I used hook_views_post_execute() function and got View 1 result set there, put it into static variable and then tried to call it in hook_views_query_alter() to alter query conditions for View 2 there, but it turned out, that Drupal calls hook_views_query_alter() for every view first and then it executes all views one by one, so it is somewhat impossible to catch View 1 results and pass them as conditions to View 2.
Am I doing something wrong or there are other ways of doing this? Is it possible at all to build one View based on results of another View?
Comments
Comment #1
damiankloip commentedYou might be able to do this with the views field view module. It allows you do pass field tokens into the child views. Although, you want to pass all the results from one view as args for the second.
Where are you calling this code? You can do this quite easily if you are invoking the views yourself and passing the data around. You can execute the first view and then do what you need with the result set.
Comment #2
damiankloip commentedSo maybe something along the lines of this:
Comment #3.0
(not verified) commentedFormatted