Return to Snippet

Revision: 44113
at October 1, 2011 17:15 by focal55


Updated Code
//OVERALL SCORE CALCULATION
$display_id = 'default';
$foo = '';
$view = views_get_view('foobar');
$view->set_display($default_id);
$view->set_arguments(array($foo));

//replace name_of_filter with your filter machine name
$view->set_display($display_id);
$filter = $view->get_item($display_id, 'filter', 'name_of_filter');
$filter['value']['value'] = $filter_value;
$view->set_item($display_id, 'filter', 'name_of_filter', $filter);

//use this to count the results of your view
$results_count = count($view->result);
//print the rendered version of your view
print $view->render();

Revision: 44112
at April 6, 2011 10:37 by focal55


Initial Code
//OVERALL SCORE CALCULATION
$view = views_get_view('foobar');
$view->set_display('default');
$view->set_arguments(array($foo));
$view->render();

/*
 * $view = is an array of your view's data
 */

//use this to count the results of your view
$results_count = count($view->result);
//print the rendered version of your view
print $view->render();

Initial URL


Initial Description


Initial Title
Drupal Views 2 & 3 Programmatically Render View with Arguments

Initial Tags
drupal, 3

Initial Language
PHP