function views_block_view in Views (for Drupal 7) 8.3
Same name and namespace in other branches
- 7.3 views.module \views_block_view()
Implement hook_block_view().
File
- ./
views.module, line 768 - Primarily Drupal hooks and global API functions to manipulate views.
Code
function views_block_view($delta) {
$start = microtime(TRUE);
// if this is 32, this should be an md5 hash.
if (strlen($delta) == 32) {
$hashes = variable_get('views_block_hashes', array());
if (!empty($hashes[$delta])) {
$delta = $hashes[$delta];
}
}
// This indicates it's a special one.
if (substr($delta, 0, 1) == '-') {
list($nothing, $type, $name, $display_id) = explode('-', $delta);
// Put the - back on.
$type = '-' . $type;
if ($view = views_get_view($name)) {
if ($view
->access($display_id)) {
$view
->setDisplay($display_id);
if (isset($view->display_handler)) {
$output = $view->display_handler
->viewSpecialBlocks($type);
// Before returning the block output, convert it to a renderable
// array with contextual links.
views_add_block_contextual_links($output, $view, $display_id, 'special_block_' . $type);
$view
->destroy();
return $output;
}
}
$view
->destroy();
}
}
// If the delta doesn't contain valid data return nothing.
$explode = explode('-', $delta);
if (count($explode) != 2) {
return;
}
list($name, $display_id) = $explode;
// Load the view
if ($view = views_get_view($name)) {
if ($view
->access($display_id)) {
$output = $view
->executeDisplay($display_id);
// Before returning the block output, convert it to a renderable array
// with contextual links.
views_add_block_contextual_links($output, $view, $display_id);
$view
->destroy();
return $output;
}
$view
->destroy();
}
}