There are many ways to insert a view in Views2, but the best way is probably the following function:

From http://groups.drupal.org/node/10129 :
Note that this function passes any additional parameters to the View as Arguments.

/**
* Embed a view using a PHP snippet.
*
* This function is meant to be called from PHP snippets, should one wish to
* embed a view in a node or something. It's meant to provide the simplest
* solution and doesn't really offer a lot of options, but breaking the function
* apart is pretty easy, and this provides a worthwhile guide to doing so.
*
* @param $name
*   The name of the view to embed.
* @param $display_id
*   The display id to embed. If unsure, use 'default', as it will always be
*   valid. But things like 'page' or 'block' should work here.
* @param ...
*   Any additional parameters will be passed as arguments.
*/
function views_embed_view($name, $display_id = 'default') {
  //... returns view output, ready to print.
}

Use page_1, page_2, block_1, block_2, ... as $display_id. You'll see the display IDs when hovering over the display names in Vews UI or in the URL when editing the displays.

Example:

   print views_embed_view("taxonomy_term", "page_1", 123 );

123 is passed as the argument.


Todo on this page:
  • Best practice for modifying and embedding a view
  • etc