Monthly Archives: February 2011

Drupal: Retrieving views results with multiple arguments

In case this catches anybody else up, you have to access the results of a view with multiple arguments by passing the arguments in as a STRING in an array. Like this:


$nodereferences = array();
foreach ($vars['form']['#node']->field_nodereference as $reference) {
$nodereferences[] = $reference['nid'];
}

$imagepathview = views_get_view('my_view_name');
$imagepathview->init_display('default');
$imagepathview->set_arguments(array(implode(',',$nodereferences)));
$imagepathview->execute();
print_r($imagepathview->result);

Very odd, and I couldn’t find anywhere on the internet that tells you this, Igot it working by trial and error.