Inserting a View anywhere in a page in Drupal 7

5 years 6 months ago

Heres a simple bit of code that will let you insert a view anywhere in a node.  This is more efficient then making a page version of a view and giving it a path.

In my opinion this code is one of the most critcal snippets for any Drupal 7 developer.  Its a basic buiding block in any site I build.

You can still use your regular node formts/meta tags/etc.

I know I'm always opening up my sites and copying this... so it must be helpfull..  I'm sorry... I don't remember where I initially found this.

$args = array("chris");
$view = views_get_view('all_posts');
print $view->preview('block',$args);