I'm having issues with a block that is created with a module I wrote. This module works on 2 out of 3 sites, all of which have a similar setup, so I'm not sure why it's being picky on one site. Here is what I know:
- The block is not showing up in the list on admin/structure/blocks, and is not available anywhere else.
- hook_block_info() is being invoked on the site, but none of the other functions are being called. On the other two sites, calls are made to all the functions.
- There aren't any blocks in the
blocks
table with the same name, but there is a record of the block in the table for each active theme. - I tried deleting these records out of the
blocks
table with no luck. - I've tried clearing cache and uninstalling/reinstalling with no luck.
Here code for my .module file. It is available here as well: http://pastebin.com/EYFgneie
/**
* Implements hook_block_info()
*/
function kcc_menu_block_info() {
$blocks = array();
//This IS being called
dpm('hook_block_info');
$blocks['kcc_menu_block'] = array(
'info' => 'KCC Menu',
'subject' => 'Menu within a block generated by a module.',
'cache' => DRUPAL_NO_CACHE,
'properties' => array(),
'weight' => null,
'status' => 1,
'visibility' => null,
'pages' => null,
'region' => 'sidebar',
);
return $blocks;
}
/**
* Implements hook_block_view()
*/
function kcc_menu_block_view($delta = '') {
$block = array();
switch($delta) {
case 'kcc_menu_block' :
//Only show this block on non-admin pages
if(!path_is_admin(current_path())) {
$block['content'] = _kcc_menu_block_view_content();
$block['title'] = _kcc_menu_block_title();
}
break;
}
return $block;
}
/**
* Implements hook_block_view_content()
*/
function _kcc_menu_block_view_content() {
$results = _kcc_menu_block_links();
return array(
'message' => array(
'#type' => 'markup',
'#markup' => $results['markup'],
'#prefix' => '<div class="kcc_block">',
'#suffix' => '</div>',
),
);
}
/**
* Function to return the entire set of 1st-level links in the sidebar menu
*/
function _kcc_menu_sidebar_links() {
return menu_tree_all_data('menu-menu-sidebar');
}
/**
* Function that returns the submenu for a specific link item out of a list of menu items.
*/
function _kcc_submenu_tree($menu_items, $mlid) {
/**
* The link returned is chosen by the mlid passed.
* An empty array will be returned if there are no children.
* $menu_items is from array returned from menu_tree_all_data()
* Sub-items of that array can be passed here
*/
foreach($menu_items as $branch) {
if($branch['link']['mlid'] == $mlid) {
$child_tree = $branch['below'];
return $child_tree;
}
}
}
/*
* Function to return the block title
*/
function _kcc_menu_block_title() {
//The value is returned along with the
//results from _kcc_menu_block_links()
$result = _kcc_menu_block_links();
return $result['title_link']['title'];
}
/*
* Function to determine and return the block content
*/
function _kcc_menu_block_links() {
$returned = array();
$sidebar_menu_links = _kcc_menu_sidebar_links();
//An array of link items representing where the
//user is currently located in the menu
$current_trail_links = menu_get_active_trail($sidebar_menu_links);
//Remove 'home' link from the current path
unset($current_trail_links[0]);
//Last item in the current trail is the current page
$current_page_link = end($current_trail_links);
reset($current_trail_links);
//Get the set of links for the first level menu item
$second_level_menu_items = _kcc_submenu_tree($sidebar_menu_links, $current_trail_links[1]['mlid']);
if($current_page_link['depth'] == 1) {
//1st level menu item with children
//Display child links for level 1 menu
$left_menu_items = $second_level_menu_items;
$title_link = $current_trail_links[1];
}
elseif($current_page_link['depth'] == 2) {
$third_level_menu_items = _kcc_submenu_tree($second_level_menu_items, $current_page_link['mlid']);
$has_children = (!empty($third_level_menu_items)) ? true : false;
if($has_children) {
//Display child links in menu
$left_menu_items = $third_level_menu_items;
$title_link = $current_trail_links[2];
//dpm('2nd level menu item with children!');
}
else {
//Display sibling links in menu
$left_menu_items = $second_level_menu_items;
$title_link = $current_trail_links[1];
//dpm('2nd level menu item without children!');
}
}
elseif($current_page_link['depth'] == 3) {
$third_level_menu_items = _kcc_submenu_tree($second_level_menu_items, $current_trail_links[2]['mlid']);
$fourth_level_menu_items = _kcc_submenu_tree($third_level_menu_items, $current_trail_links[3]['mlid']);
$has_children = (!empty($fourth_level_menu_items)) ? true : false;
//Display child links for level 2 menu
//whether or not there are children
if($has_children) {
//dpm('3rd level menu item with children');
$left_menu_items = $third_level_menu_items;
$title_link = $current_trail_links[2];
}
else {
//dpm('3rd level menu item without children');
$left_menu_items = $third_level_menu_items;
$title_link = $current_trail_links[2];
}
}
elseif($current_page_link['depth'] == 4) {
//Display child links for level 3 menu
//dpm('4th level menu item without children');
$third_level_menu_items = _kcc_submenu_tree($second_level_menu_items, $current_trail_links[2]['mlid']);
$fourth_level_menu_items = _kcc_submenu_tree($third_level_menu_items, $current_trail_links[3]['mlid']);
$left_menu_items = $fourth_level_menu_items;
$title_link = $current_trail_links[3];
}
else {
$left_menu_items = null;
}
$returned['title_link'] = $title_link;
$returned['markup'] = '<ul>';
foreach($left_menu_items as $left_menu_item) {
$returned['markup'] .= "<li><a href=\"/{$left_menu_item['link']['href']}\">{$left_menu_item['link']['title']}</a></li>";
}
$returned['markup'] .= '</ul>';
return $returned;
}
I've exhausted all of my knowledge, so I'm up for any and all suggestions. Thanks in advance for you help!