I've created a patch that adds another menu_block configuration setting.

Basically when you set Starting level to "Children of active menu", it allows you to choose whether or not you still want the menu to show at end-of-the-line items, albeit with their siblings as links.

Example menu:

Link 1
Link 2
  Link A
    Link i
    Link ii
    Link iii
    Link iv
    Link v
  Link B
Link 3

When navigating to 1 > A > iv, the menu would normally disappear.
With patch in comment #1 and the toggle enabled, it will show:

Link A
---------
  Link i
  Link ii
  Link iii
*Link iv*
  Link v

Seeing as I needed this functionality myself, I can already assure you that this patch works nicely.
I just thought it could contribute to this awesome module :)

P.S.: I think this issue may be related to and/or fix #758184: Ability show items on same level if active menu level don't have children and #1125154: "Deepest item in the active trail with visible siblings" as option for follow_parent.

Comments

kristiaanvandeneynde’s picture

Patch as promised.

kristiaanvandeneynde’s picture

Issue summary:View changes

Typo

matthewcornish’s picture

Version:7.x-3.x-dev» 6.x-2.4
Category:feature» support

Hi there Kristiaan, your patch is AWESOME and I've made use of it in Drupal 7 installations, however, I'm wanting to apply it in a drupal 6 installation and the 3rd/4th hunks in menu_block.admin.inc won't patch (appears function menu_block_configure_form and function _menu_block_block_save) are different. I'm trying to sort this out myself atm but you might understand it well enough to be able to help quicker :) if you have the time I'd appreciate some guidance, please.

matthewcornish’s picture

Version:6.x-2.4» 7.x-2.3
Category:support» feature

I've fixed the problem. For 6.x-2.4 (menu_block.admin.inc) you don't appear to need

@@ -436,7 +448,7 @@ function menu_block_configure_form($form, &$form_state) {
   $form['menu-block-wrapper-close'] = array('#markup' => '</div>');

   // Set visibility of advanced options.
-  foreach (array('title_link', 'follow', 'follow_parent', 'expanded', 'sort', 'parent_mlid') as $key) {
+  foreach (array('title_link', 'follow', 'follow_parent', 'show_deepest', 'expanded', 'sort', 'parent_mlid') as $key) {
     $form[$key]['#states']['visible'][':input[name=display_options]'] = array('value' => 'advanced');
   }
   if ($config['title_link'] || $follow || $config['expanded'] || $config['sort'] || $config['parent_mlid']) {

So apply the patch as normal and then manually paste the additional line from hunk 4
+      variable_set("menu_block_{$delta}_show_deepest", $edit['show_deepest']);
...into...

function _menu_block_block_save($delta, $edit) {
  variable_set("menu_block_{$delta}_title_link", $edit['title_link']);
  variable_set("menu_block_{$delta}_admin_title", $edit['admin_title']);
  variable_set("menu_block_{$delta}_parent", $edit['parent']);
  variable_set("menu_block_{$delta}_level", $edit['level']);
  variable_set("menu_block_{$delta}_show_deepest", $edit['show_deepest']); /* new addition */
  variable_set("menu_block_{$delta}_follow", $edit['follow']);
  variable_set("menu_block_{$delta}_depth", $edit['depth']);
  variable_set("menu_block_{$delta}_expanded", $edit['expanded']);
  variable_set("menu_block_{$delta}_sort", $edit['sort']);
}

...and voila! I'll continue to test but early indications are good :)

kristiaanvandeneynde’s picture

Priority:Normal» Critical

Glad you like the patch.

Let's make sure this gets noticed after 3 months of just sitting in the queue.

capellic’s picture

Any way of showing siblings while keeping the Starting level to as "1st level (primary)"?

kristiaanvandeneynde’s picture

@capellic I'm not sure if I know what you mean...

houstonaplus’s picture

Just wanted to say your code works beautifully. This should be a must have feature.

houstonaplus’s picture

Issue summary:View changes

More typos

Dave Reid’s picture

Priority:Critical» Normal
Issue summary:View changes

Feature requests by nature are not critical.

Jorge Navarro’s picture

Your patch was not working for me when having more than 4 levels. Here I am submitting a new path that works for all levels.

gmclelland’s picture

Version:7.x-2.3» 7.x-2.x-dev

@kristiaanvandeneynde your patch in #1 no longer applies to 7.x-2.x-dev

+++ b/menu_block.module
@@ -335,7 +337,7 @@ function menu_tree_build($config) {
-    menu_tree_prune_active_tree($tree, $config['follow']);
+    menu_tree_prune_active_tree($tree, $config);

This line of code is no longer in the 2.x-dev version

@Jorge Navarro - Is your patch to be combined with the patch in #1?

kristiaanvandeneynde’s picture

@gmclelland (#10): Try this patch.
@Jorge Navarro (#9): I have no idea what your goal is :) Is that patch meant to be merged into the one I made, or is it a very concise stand-alone?

@Dave Reid (#8): I know it isn't critical, but the patch was working fine for some two years already and it seems people like it. Marked it as critical to draw your attention and because at some point in time I believe the "Issue priority guideline" actually said to bump your issues after a while of inactivity. Doesn't seem to be in the current draft, though.

gmclelland’s picture

@kristiaanvandeneynde - Thanks for the quick patch. I applied it and it seems to work as expected.

There is also another patch at #1125154: "Deepest item in the active trail with visible siblings" as option for follow_parent that seems to do the same thing, but doesn't change the module code as much. It doesn't set new variables or change function parameters. Maybe that patch would be better?

gmclelland’s picture

I don't know how, but I tested the one line patch in #1620298: Add new starting level option "Children of active menu item, and active menu item if no children" and it seems to do the same thing as well.

kristiaanvandeneynde’s picture

The reason my patch has more code is because it properly adds/removes database variables for the options and provides a more intuitive UI. The patch in #1125154: "Deepest item in the active trail with visible siblings" as option for follow_parent is basically doing the same, but in a slimmed-down approach.

Jorge Navarro’s picture

My patch is a new patch. The patch changes the module to show the menu (the previous, with siblings) if you are at deepest level, so when you arrive to deepest level, the menu doesn't disappear.

kristiaanvandeneynde’s picture

Bump.

I know Dave Reid has a zillion modules to maintain, but this is a patch that people have tried, tested and loved for well over two years now. Could this get some love please?

Hi there Kristiaan, your patch is AWESOME and I've made use of it in Drupal 7 installations

Just wanted to say your code works beautifully. This should be a must have feature.

kristiaanvandeneynde’s picture

Status:Needs review» Reviewed & tested by the community
Dave Reid’s picture

Status:Reviewed & tested by the community» Needs review
+++ b/menu_block.module
@@ -641,14 +643,14 @@ function menu_tree_prune_tree(&$tree, $level, $parent_item = FALSE) {
-function menu_tree_prune_active_tree(&$tree, $level) {
+function menu_tree_prune_active_tree(&$tree, $config) {
   module_load_include('inc', 'menu_block', 'menu_block.follow');
-  _menu_tree_prune_active_tree($tree, $level);
+  _menu_tree_prune_active_tree($tree, $config['follow'], $config['show_deepest']);

The only thing I can find is that this is an API change for menu_tree_prune_active_tree(). Would it be better just to add the third parameter like was done to _menu_tree_prune_active_tree() above?

kristiaanvandeneynde’s picture

That could be done, yes.

The best way would be to start passing $config around to every function that may need to read something out of it. That way, future patches wouldn't need to append yet another parameter to the function definition. However, that does result in an API change. So if you're reluctant about it, I understand completely.

Dave Reid’s picture

Status:Needs review» Needs work

While we could change the API in 7.x-3.x, I don't think we should change a publicly-available API in 7.x-2.x since it has stable releases.