Node Revisioning VID used for views argument

604 views Asked by At

I've built a node reference field that allows multiple multi-media content types to be accessed. I then threw it together in a view so I could group based on content type, so images are with images, documents with documents, etc. All works fine with the node NID argument for displaying on regular pages, and content won't display if the field is empty. However, this has to work with revisioning as well. Node NID as an argument displays the current published version of my node reference field, not the latest revision version. Node Revision VID does not have a default argument to set it to, so if you leave it as display all values you wind up with the view displaying on any page with empty values. Printing the node reference field using

<?php foreach ((array)$field_FIELD as $item) {
print $item['view'];
}
?>

will print out all the fields, but they aren't grouped by content type. Printing the view in the tpl file looks something like

 <?php
    $view = views_get_view('my_view_name');
$args = array($vid);   
 $output = $view->preview('block_4', $args);
    if (!empty($view->result)) {
      print $output;
    }
    ?>

but the argument doesn't work. I need to pass the latest revision from the URL into either my views argument so it will only display on that particular page or figure out a way to group my foreach loop into content types. Any suggestions or help would be greatly appreciated.

1

There are 1 answers

1
Clive On

Following the chain all the way down from preview() to set_arguments(), it looks like you need to be passing an array as your arguments.

$args = array($vid);
$output = $view->preview('block_4', $args);