Views Field View – what works and what irks

Views field view allows you to pass an argument to a view and return results.

For the video inclined here’s the 2 minute feed

Use Case:  we’ve got a lot of variables being tallied in different views.  Views in general seems an awkward tool for tabulating values.  Tools like views calc and group by work ok for getting a sum or count here and there, but try mixing several together in one view and the errors start to fly.  May just be I don’t have my head around them, in any case they are not intuitive.   For a given organic group node I need to know how many posts there are total (not a problem, that field comes with organic group views integration), and how many of these posts have been completed in a certain way.

Views field view added to fields in view

Views field view added to fields in view

Choose a view and add fields from the view as argument tokens

Choose a view and add fields from the view as argument tokens

Creating this separate view is simple, but now I want to link the main view to the small view tally.  Views Field View let’s you pick a view and pass it an argument to filter the results per row.  In this case we load a node id into our main view and pass the argument over to the Views Field View – creating a new field with the correct info on a per row basis = Nice!

The only thing that doesn’t work is that it does not actually load this view in the order the rows are listed.  Because of this it does not work well with Views PHP.  Although the rows are listed in this global php field the actual data is not available because for some reason the field is not loaded in the order one might imagine it to be.   It’d be really handy to be able to use these variables in calculations, however it’s just not obvious at all how to do that.

Views PHP and VIews Field View don't work together

Views PHP and VIews Field View don't work together


This entry was posted in Planet_Drupal and tagged , , , , , . Bookmark the permalink.

9 Responses to Views Field View – what works and what irks

  1. Mike Kadin says:

    Good stuff. I’ve been in similar situations before and haven’t been too happy with the results and the hoops that you have to jump through. That’s why I started work on a module called Report Builder ( which solves some of the problems it looks like you are trying to solve.

    Have a look see! I’m looking for a few developers to help me get the project production-ready.

    • alibama says:

      Hi Mike, that’s very cool, we’re running D6 right now, however am certain that a solid analytics tool is needed across the board – all of them seem somewhat wonky. Don’t suppose you have any module recommendations for D6?

  2. Pingback: Drupal 6 + Modules we Love Volume 1, Views | Wordpress VS Drupal

  3. ReynierPM says:

    I’m using D6 and Views 2 but installed views_field_view and can’t see it under my Views UI, why?

  4. alibama says:

    I had a lot of problems and my use case changed = so i ended up loading the view programmatically using “views_get_view”

    nid_1; // the argument to pass
    $total = views_get_view(‘completed_students’); // the view name
    $test=print_r($total->render(),true); // this is a silly hack to get my view output as a string
    $test2=settype($test, “integer”); //now i get my result and can mess with it as an integer

    if ($test3==0)
    echo “Questionnaire not Started”;
    echo round(100*($test3/($row->member_count-28)),2);


  5. ReynierPM says:

    Hmmm I’m not so expert at Drupal, yet, so I may ask where this code should go? How do I know what values get nid? See I have this content and for each Author which is a content type by himself I need to get all the Experts (which is a kind of content type wrote by Authors). Can you help me to get this?