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:

<?php
/**
* 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

Version:7.x-2.2» 7.x-2.x-dev
Status:Active» Needs review
StatusFileSize
new718 bytes

By the way: Is there a update-save method to overwride methods of a module/core (e.g. in the template.php)?

Overriding 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.

Thanks for your patch. It fixes the problem.

Status:Needs review» Needs work

Doesn't seem to be working for me. When trying to debug it, $tree[$key]['below'] is empty for the children of a <front> link.

Status:Needs work» Reviewed & tested by the community
StatusFileSize
new1.11 KB

Whoops, 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.

Thx! Works fine.

Title:Show submenus of frontpage (<front>)Child menu items don't appear when current page is front page
Status:Reviewed & tested by the community» Fixed

Thanks, everyone! You've all got credit on your user page now. :-)

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.