Commit 79b691b0 authored by davereid's avatar davereid Committed by Dave Reid

Issue #2315201 by alexshipilov, Dave Reid: Fixed contextual links missing when...

Issue #2315201 by alexshipilov, Dave Reid: Fixed contextual links missing when menu block rendered from a CTools content type plugin (via Panels).
parent 86d54707
......@@ -135,18 +135,24 @@ function menu_block_help($path, $arg) {
*/
function menu_block_block_view($delta = '') {
$config = menu_block_get_config($delta);
$data = menu_tree_build($config);
// Add contextual links for this block.
if (!empty($data['content'])) {
if (in_array($config['menu_name'], array_keys(menu_get_menus()))) {
$data['content']['#contextual_links']['menu_block'] = array('admin/structure/menu/manage', array($config['menu_name']));
}
elseif (strpos($config['menu_name'], 'book-toc-') === 0) {
$node = str_replace('book-toc-', '', $config['menu_name']);
return menu_tree_build($config);
}
/**
* Implements hook_block_view_alter().
*/
function menu_block_block_view_alter(&$data, $block) {
// Add contextual links for menu blocks.
if ($block->module == 'menu_block' && !empty($data['content']['#config'])) {
$menu_name = $data['content']['#config']['menu_name'];
if (in_array($menu_name, array_keys(menu_get_menus()))) {
$data['content']['#contextual_links']['menu_block'] = array('admin/structure/menu/manage', array($menu_name));
}
elseif (strpos($menu_name, 'book-toc-') === 0) {
$node = str_replace('book-toc-', '', $menu_name);
$data['content']['#contextual_links']['menu_block'] = array('admin/content/book', array($node));
}
}
return $data;
}
/**
......
......@@ -89,7 +89,10 @@ function menu_block_menu_tree_content_type_render($subtype, $conf, $args, $conte
$tree = menu_tree_build($conf);
$block = new stdClass();
$block->subtype = $conf['menu_name'];
$block->module = 'menu_block';
// Add contextual links.
menu_block_block_view_alter($tree, $block);
$block->subtype = isset($tree['content']['#config']['menu_name']) ? $tree['content']['#config']['menu_name'] : $conf['menu_name'];
$block->title = $tree['subject'];
$block->title_array = $tree['subject_array'];
$block->content = $tree['content'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment