The current version of Menu block does not show subnodes of the frontpage until they are selected. I've created a modified version of menu_tree_prune_tree() in the menue_block.module file. Perhaps this will be implemented in next releases of this really useful module.
Here is the code:
/**
* Prune a tree so that it begins at the specified level.
*
* This function will follow the active menu trail to the specified level.
*
* @param $tree
* array The menu tree to prune.
* @param $level
* int The level of the original tree that will start the pruned tree.
* @param $parent_item
* array The menu item that should be used as the root of the tree.
* @return
* void
*/
function menu_tree_prune_tree(&$tree, $level, $parent_item = FALSE) {
...
// Trim the upper levels down to the one desired.
for ($i = 1; $i < $level; $i++) {
$found_active_trail = FALSE;
// Examine each element at this level for the active trail.
foreach ($tree AS $key => &$value) {
if ($tree[$key]['link']['in_active_trail']) {
// Get the title for the pruned tree.
menu_block_set_title($tree[$key]['link']);
// Prune the tree to the children of the item in the active trail.
$tree = $tree[$key]['below'] ? $tree[$key]['below'] : array();
$found_active_trail = TRUE;
break;
} else {
if($tree[$key]['link']['link_path'] == '<front>' && drupal_is_front_page()) {
// Get the title for the pruned tree.
menu_block_set_title($tree[$key]['link']);
// Prune the tree to the children of the item in the active trail.
$tree = $tree[$key]['below'] ? $tree[$key]['below'] : array();
$found_active_trail = TRUE;
break(2);
}
}
}
...
}
By the way: Is there a update-save method to overwride methods of a module/core (e.g. in the template.php)?
Cheers,
Rafael Kutscha
Comments
Comment #1
pjcdawkins commentedOverriding is made possible in modules via hooks, and in themes via template files and preprocess functions. If you're trying to change something that isn't available in a module's hook, then that is effectively adding a new feature or fixing a bug. So in that case the best thing to do is to create an issue, as you have done. Ideally if you have the resources (e.g. git), create a patch.
Anyway, attached is my (untested) patch for the fix you've suggested.
Comment #2
petu commentedThanks for your patch. It fixes the problem.
Comment #3
tim.plunkettDoesn't seem to be working for me. When trying to debug it,
$tree[$key]['below']is empty for the children of a <front> link.Comment #4
tim.plunkettWhoops, I had tested it without checking "Expand all children of this tree." for that specific block.
I rerolled the patch to minimize calls to
drupal_is_front_page()and added a comment, but I'm still going to RTBC because it is the correct fix.Comment #5
tobiasbThx! Works fine.
Comment #6
johnalbinThanks, everyone! You've all got credit on your user page now. :-)