How to display node when view contains only 1 item? I have a custom view which displays all nodes of a specific content-type off the main menu.  You can click on any of the teaser headers and see the individual node data.

I have been asked to display this drill down-detailed view if there is only 1 item in the main view rather than forcing the user to click through another layer to get to the detail view.

Any thoughts on how to hook into this and which hook to call to override the defined view and jump directly to the node view?
My approach is to count the views result first. If the result is only one I will get the node id and load it using entity_load_single and render according to whatever you want.

Pseudo code:

function hook_name_or_callback() {
  // Get the view.
  $view = views_get_view($view_name);
  // Based on $view you can get the views result.
  if (result_is_one) {
    $node = entity_load_single('node', NID);
    $node_view = node_view($node);
    return drupal_render($node_view);
  }
  else {
    // Just display the view.
  }
}


P.S: Haven't test this code and might not work for you.

See these:

https://api.drupal.org/api/views/views.module/function/views_get_view/7.x-3.x
http://www.drupalcontrib.org/api/drupal/contributions!entity!entity.module/function/entity_load_single/7