Drupal 6 revisted: Passing arguments through filters in Views
<?php
$view = views_get_view('view_name'); // fetch the view
$display_id = 'default'; // chose the display type
$view->set_display($display_id);
$view->is_cacheable = FALSE;
$item = $view->get_item($display_id, 'filter', 'distance');// telling the view that we are fetching filter. distance is the filter name. We can check the filter name from view export as well.
$item['value'] = array('postal_code'=>'00210', 'search_distance'=>'100', 'search_units'=>'mile'); // passing values to all the exposed filter. We can pass other options like operator etc (not just value) as well.
$view->set_item($display_id, 'filter', 'distance', $item); // set item
$view->is_cacheable = FALSE;
$output = $view->render(); // render
print $output; // display output
?>

Post Comment