Posted By

focal55 on 04/06/11


Tagged

drupal views 2 3 6


Versions (?)

Drupal Views 2 & 3 Programmatically Render View with Arguments


 / Published in: PHP
 

  1. //OVERALL SCORE CALCULATION
  2. $display_id = 'default';
  3. $foo = '';
  4. $view = views_get_view('foobar');
  5. $view->set_display($default_id);
  6. $view->set_arguments(array($foo));
  7.  
  8. //replace name_of_filter with your filter machine name
  9. $view->set_display($display_id);
  10. $filter = $view->get_item($display_id, 'filter', 'name_of_filter');
  11. $filter['value']['value'] = $filter_value;
  12. $view->set_item($display_id, 'filter', 'name_of_filter', $filter);
  13.  
  14. //use this to count the results of your view
  15. $results_count = count($view->result);
  16. //print the rendered version of your view
  17. print $view->render();

Report this snippet  

You need to login to post a comment.