How to print views from a theme: use PHP to insert views directly into a template
This is useful for custom home pages (page-front.tpl.php), and can also be used in custom modules that provide pages.
Not the answer! This is for putting a view directly into a node: http://drupal.org/project/insert_view
There are at least two ways to print a view directly from your theme, custom module page, or PHP input format page:
Dan and I feel safer with the above way-- printing it through block. To be specific... "I am Dan Hakimzadeh and I approve this message." In this case Agaric's view is named 'actions'.
//get the view
$view = views_get_view('actions');
//build the view
//$args is an array of arguments to pass in
//$use_pager - boolean, default FALSE
//$limit - int, default 0
//$page - int, default 0
$block = views_build_view('block', $view, $args, $use_pager, 5, $page);
print $block ;
The way I always have done it:
//load the view by name
$view = views_get_view('sample_view');
//output the view
print views_build_view('embed', $view);
See these warnings! If your view isn't working, it may have nothing to do with this code. Maybe, your view isn't enabled at all or for the page or block you are calling.