function views_add_block_contextual_links in Views (for Drupal 7) 8.3
Same name and namespace in other branches
- 7.3 views.module \views_add_block_contextual_links()
Converts Views block content to a renderable array with contextual links.
Parameters
$block: An array representing the block, with the same structure as the return value of hook_block_view(). This will be modified so as to force $block['content'] to be a renderable array, containing the optional '#contextual_links' property (if there are any contextual links associated with the block).
$view: The view that was used to generate the block content.
$display_id: The ID of the display within the view that was used to generate the block content.
$block_type: The type of the block. If it's block it's a regular views display, but 'special_block_-exp' exist as well.
1 call to views_add_block_contextual_links()
- views_block_view in ./
views.module - Implement hook_block_view().
File
- ./
views.module, line 837 - Primarily Drupal hooks and global API functions to manipulate views.
Code
function views_add_block_contextual_links(&$block, ViewExecutable $view, $display_id, $block_type = 'block') {
// Do not add contextual links to an empty block.
if (!empty($block['content'])) {
// Contextual links only work on blocks whose content is a renderable
// array, so if the block contains a string of already-rendered markup,
// convert it to an array.
if (is_string($block['content'])) {
$block['content'] = array(
'#markup' => $block['content'],
);
}
// Add the contextual links.
views_add_contextual_links($block['content'], $block_type, $view, $display_id);
}
}