You are here

function views_view_block in Views (for Drupal 7) 5

This views a view by block. Can be used as a callback or programmatically.

1 call to views_view_block()
views_block in ./views.module
Implementation of hook_block()

File

./views.module, line 423

Code

function views_view_block($vid) {
  views_load_cache();
  $view = views_get_view($vid);
  if (!$view || !$view->block) {
    return NULL;
  }
  global $user;
  if (!$user->roles) {
    return NULL;
  }
  $roles = array_keys($user->roles);
  if (!views_access($view)) {
    return NULL;
  }
  $content = views_build_view('block', $view, array(), false, $view->nodes_per_block);
  if ($content) {
    $block['content'] = $content;
    $block['subject'] = filter_xss_admin(views_get_title($view, 'block'));
    return $block;
  }
  else {
    return NULL;
  }
}