I want to embed a view in the tpl.php, so I am using the views_get_view('VIEWNAME') function.
Here is what I am doing the tpl.php:
<?php
$view = views_get_view('MapView');
print $view->preview('default');
?>
“MapView” is the view’s name, I am not sure the argument in the views_get_view is the machine name or human readable name, in fact in my example is using the human readable name, because I can’t find the machine name in the drupal view configuration.
Anyway, I get a error saying “Fatal error: Call to a member function preview() on a non-object“, seems like I didn’t fetch the view in the correct?
any idea?
View id you can easly get from edit view url. Like any key it consists of undescores and lowercase.
Also to output view in needed place try it:
It worked for me for node content, i added view to the nodes of needed type in my module: