Dcycle Blog

Embedding a view and intercepting its output in your code

October 15, 2014

$view = views_get_view('my_view_machine_name');
$view->set_display('block');
$view->set_arguments(array($arg1, $arg2));
// change the amount of items to show
$view->pre_execute();
$view->execute();
// you can change $view->result here if you want. Use the
// devel module and dpm($view->result) to inspect what
// it looks like.
return $view->render();