Is there any performance implications in calling a view programmatically and set necessary filters? I have a view that list some items depending on the current node loaded. I also want to add few exposed filters to the view. The exposed filters cannot be shown to users directly. I want to provide a separate set of filters (to display) for users and based on what user selected, I want to set one or more filters of the view.

For example: I want an option for user to show only nodes that are not older than 7 days, 14 days etc so I will provide a list with All, 7 days, 14 days etc and when user select any of these, I want to set the exposed filter for node created time and with the calculated value - the date 7 days or 14 days or so from now.

There are several filters like this - ie based on what the user selected, we need to apply different filters in view. 

To implement this, I plan to implement a block, in which I can programmatically call a view 

$my_view_name = 'the_view';
$my_display_name = 'block';
$my_view = views_get_view($my_view_name);
$my_view-&gt;set_display($my_display_name);

if ($option == FIRST_OPTION) {
  $my_view-&gt;exposed_input['filter1'] = $option1_calculated_value1;
  $my_view-&gt;exposed_input['filter2'] = $option1_calculated_value2;
}  
else {
  $my_view-&gt;exposed_input['filter1'] = $option2_calculated_value1;
  $my_view-&gt;exposed_input['filter2'] = $option2_calculated_value2;
  $my_view-&gt;exposed_input['filter3'] = $option2_calculated_value3;
}  

$my_view-&gt;execute(); 
unset($my_view-&gt;exposed_widgets);
return $my_view-&gt;preview();


Is there any problem in using this method? Is there any other way to do this? Is there any performance implications in using this method? Will views caching etc work in this case? I use Drupal 7 and Views 7.x-3.7
Definitely not an issue unless you overload the view (but you can do that with the UI also - so no difference there). 

On our production architecture we have views UI disabled and all the views are in code under version control however we also have a content team that needs to build 'lightweight views' that pull data from a product catalog and displays it in a particular way. Unfortunately we don't want them running direct SQL or using views UI as they don't completely understand what it all means so we just programmatically create these views and expose a UI to them that they understand. Things like:


What design they want on it
How they want the sorting of the dataset
Whether they need 'no results' text
etc.


Some caveats to doing more complex versions of this are:


Looking out for timing issues. I.e. not having an option available at that call point
Ensuring the correct structure is used. Example: $view-&gt;use_ajax vs $view-&gt;display[$dispay_id]-&gt;filters['use_ajax'].


Neither the less, it is all definitely possible and scales without issues.