Drupal 5: Embedding a view in a page or node layout

Here is how you can generate the html from a view and embed into a page callback or node.

<?php
function MYMODULE_MYFUNCTION() {
  // ...code...
  // define view name
  $viewName = 'MY_VIEW';

  // get the view object
  $view = views_get_view($viewName);

  // create an array of arguments
  // NOTE: if you are using arguments, you can pass them into this function
  $viewArgs = array();

  // create view html
  $viewHtml = views_build_view('block', $view, $viewArgs, FALSE, $view->nodes_per_block);

  if ($viewHtml) {
    $page_contents .= "<h3>" . $view->block_title . "</h3>";
    $page_contents .= $viewHtml;
  }
  // ...code...
}
?>

In this example, I am using a block view. You can also use a page or embedded layout and adjust as necessary. I find it helpful to show the contents of the view object to see what's available to you. For instance:

<?php
echo "<pre>" . print_r($view, TRUE) . "</pre>";
?>