Use case:

I'm trying to build a view similar to Google Directory, with a category browser along the top, and a list of nodes matching the current category on the bottom. There's nothing too overly complicated here. We're basically talking about two views: one at the top that's a "Term" type view, taking Parent term as the argument, and one at the bottom that's a "Node" type view, taking Term ID as an argument and displaying a list of nodes below:

Google Directory in Views

The challenge is that Views doesn't let you combine two different "types" of views to the same view. While you can add an attachment to another display, you can only do so within the same physical view, and those two views must therefore have the same basic type. These don't.

However, I think this would be possible with an extension to the Views Attach module. There would be some caveats; namely, that both views would require to act on the same URL input for the argument. The workflow would probably be selecting the View to attach it to, and then selecting the Display within that view.

Comments

eaton’s picture

Spent some time thinking this over. In a way it's close to the sort of 'attached' view that the Views module normally offers. Instead of pointing to a display on the current view, however, you'd need to pick another view and then a display on that view.

As long as the argument values could be mapped to each other, it could work.

I'm brainstorming now. Hmmmm.

Fr0s7’s picture

My initial instinct is to use the standard Views 'attachment' display, and set up your content types in such a way that you can use the same physical View for everything.

That thinking aside, the top view is really just a selection form and the bottom view is the results. You might be able do this by using something similar to Views Bulk Operations, where the user selects terms from one view as the input form, the form is submitted, and then an Action is used to pass the argument to a specific URL. This target URL is the page display of the receiving view, which displays the results.

You might be able to display these two views on the same page by using Panels. I'm not even sure using Views Attach is the right way to go about this, but it's an interesting challenge.

BartVB’s picture

"but it's an interesting challenge"

:) That's what I learned in the last few weeks... I'm fairly new to Drupal and my current project entails a scenario almost exactly like what Webchick describes.

I have a number of nodes (CKK) ordered in a taxonomy tree. Exposed filters can be used to filter on things like keyword, location, etc and there is an argument which limits the display/search to a part of the taxonomy tree.

My current plan of attack is modifying view_handler_argument.inc which can display a summary of terms if no argument is present. I need this to honor the filters, the arguments and figure out what the child terms are. So maybe using two separate views (one with Type = node, one with Type = term) is indeed a better way to go.

I wish I knew what I was heading into before I started this, when drawing this up it seemed like a trivial feature but now I find myself diving into the guts of Drupal right away :) At least I don't feel stupid now that I've found out that Webchick is running into the same problems as I did. So with my ego in check again all that's left is a proper solution.

IntoTheWoods’s picture

Another possible avenue to explore is to use a views custom field (views_customfield module) to add a php snippet in your view (header, field, or footer) which embeds a second view into the first.

$viewName = 'attachedViewName';
$display_id = 'block';
$myArg = $data->field;
print views_embed_view($viewName, $display_id, $myArg);

I've only started checking out this approach, but my initial attempts have looked promising.

NikLP’s picture

I've been having similar thoughts about views recently... I looked at all sorts of ways of achieving what Webchick is trying to do, but the best I could come up with was coding a custom module to perform the relevant queries and display the results. This isn't great of course as it lacks the ease & customisability of Views.

Then I recently thought that if views_attach can attach a view to a node, why the hell couldn't it attach one to another view as well? Seems like nearly all the relevant bits are available... just needs some code to achieve the attaching, I think?

That's the end of my long-winded "subscribe" message :)

joachim’s picture

This is what image module's gallery has been doing for ages ;)

Kludgy, but with Views 3 should hopefully be less so: http://drupal.org/project/views_catalog

hixster’s picture

subscribing

ashedryden’s picture

This worked great for me.

schaeferwebsolutions’s picture

This is great! Thanks so much.

NikLP’s picture

Anyone want to highlight how this is achievable now?

JayShoe’s picture

I'm pretty sure the answer to this issue is https://drupal.org/project/views_field_view.