Hi!

Thanks for a great module.

One problem though. If you have a multilingual view for example, and you have a menu for all the languges of the site, and you reference the view through multiple menu items, the Menu Block just shows on one of these pages. The Menu block does not seem to be able to handle multiple menu items pointing to the same destination.

Issue fork menu_block-618700

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DrupalNovice’s picture

Version: 6.x-2.x-dev » 6.x-2.2
stoltoguzzi’s picture

the same here!

ressa’s picture

Yes, the menu block disappears when on a view page, except for the default language.

The block is shown on this page:
/references/pictures

but no on this:
/fr/references/pictures

ressa’s picture

I ditched the page views, since their paths caused the problem, and now only use blocks, displaying them in the content area: http://drupal.org/node/130389#comment-2362658

DomoSapiens’s picture

Same problem here!

I have two menu items (English and Dutch) to a vocabulary index called "tags".
On the English page the menu block dissappears when i'm on the vocabulary index page.

The block is visible on /tags
It's invissible on en/tags

mlncn’s picture

Problem for other menu items, to give an example that's not multilingual related.

benjamin, agaric

mlncn’s picture

There are two parts of menu_block that seem to fail

The harder to fix is menu_tree_add_active_path() which cuts out -- stops looking and deletes other branches of the tree -- when it finds the first active menu item. It short-circuits Drupal's usual behavior of allowing multiple active paths in one tree and only allows one.

function menu_tree_add_active_path(&$tree) {

// ...

  // To traverse the original tree down the active trail, we use a pointer.
  $subtree_pointer =& $tree;
  // Find each key in the active trail.
  while ($tree_with_trail) {
    foreach (array_keys($tree_with_trail) AS $key) {
      if ($tree_with_trail[$key]['link']['in_active_trail']) {
        // Set the active trail info in the original tree.
        $subtree_pointer[$key]['link']['in_active_trail'] = TRUE;
        // Continue in the subtree, if it exists.
// So here's the problem - once we find one active path, everything else gets thrown out.
// This whole function - the foreach loop - has to be changed
        $tree_with_trail =& $tree_with_trail[$key]['below'];
        $subtree_pointer =& $subtree_pointer[$key]['below'];
        break;
      }
      else {
        unset($tree_with_trail[$key]);
      }
    }
  }
}
FiNeX’s picture

This problem is a big problem... someone can suggest a workaround?

ressa’s picture

Have you looked at the approach referred to in post #4? - http://drupal.org/node/130389#comment-2362658

FiNeX’s picture

I didn't really understand it :-(

FiNeX’s picture

After some testing I've tried this solution which partially works:

Primary links
- menu 1 (en)
- - sub menu 1.1 (en)
- - sub menu 1.2 (en)
- - sub menu 1.3 (menu created by the views module)
- menu 2 (it)
- - sub menu 2.1 (it)
- - sub menu 2.2 (it)
- - sub menu 2.3 (menu manually created which links the views path)

1, 1.1, 1.2, 2, 2.1 and 2.2 are menu which links a node page. menu 1 links to the english version of menu 2 (which is the italian one).
sub menu 1.3 and sub menu 2.3 links a view which displays all story nodes with the current language.

The default language is "it". When I visit the sub menu 2.3, the menu_block is visible: it correctly display sub menu 2.1, 2.2 and 2.3. If I switch (with the languageblock switcher) to the english version, the views correctly loads, but the menu_block is not displayed anymore.

I hope to have well explained my situation and I really hope to find a solution to solve this issue :-(

Thanks in advance to everyone!

FiNeX’s picture

I've done an extra test: I've enabled the "menu breadcrumb" module so I can check the "trail".

When I click on "sub menu 1.3" the breadcrumb is:
* Home > sub menu 1.3
When I click on "sub menu 2.3" the breadcrumb is:
* Home > menu 1 > sub menu 1.3

It looks like only the menu I've manually addedd knows how is his father :-(

FiNeX’s picture

This problem looks similar: http://drupal.org/node/400748

ressa’s picture

It's pretty straightforward though, just use a Views Block, not a Views Page:

1. Make a Views Block, with the same content as the Views Page you are trying to fix.
2. Make a normal Page (not Views), note down the path and put it where you originally wanted you Views Page. You will put the Views Block after the content of this page.
3. Under the Block settings (admin/build/block), specify it to be shown ONLY on that path you copied under content.
4. Now you have a normal menu item, from the page, and therefore a menu block AND the breadcrumb also works...

Ask if it still isn't clear!

FiNeX’s picture

#14: I know that way, it was my first thought... unfortunatly the website structure is very complex with hundred of pages; sub menus should be putted on lot of them, so you have to edit the block settings for each new page you add... trust me, in this case it is not a solution :-(

I've found a different solution. I've configured the primary links i18n_variable and now there are two primary links, one for each language. Subsequently I've added a second menu_block. Now I've two menu blocks, one for each menu, so there is one for each language... and it works: the menu doesn't seems disappear anymore (in fact there are two menus, and only one is visible) :-) :-)

So we can consider that the specific case when two links points to a view and we're on a webiste which uses i18n (and the two links are the localized links) can be solved with the described procedure or with the #14 trick.

Anyway both of them aren't the real solution of the initial problem but only workarounds for specific situations.

At least I've solved my specific problem for the menu block, not yet for the menu_breadcrumb (http://drupal.org/node/400748)... but I'll solve it either. Thanks ressa for answering me :-)

Bye

ressa’s picture

You're welcome 8o)

Nice workaround you thought out, you probably did what this guy explains here, right? http://drupal-translation.com/content/managing-translated-menus ...that solution is better for a complex site, I agree.

For now I will stick to the other workaround, since it has these benefits:
- No need to set URL aliases
- Meta tags for all languages
- Easier for the editor, since everything now is pages, in stead of a mixture of normal pages and page views, which have to be translated in different ways.
- Less need for custom_breadcrumbs, since large parts of the paths are now ordinary menu paths, and can be generated with menu_breadcrumb

JohnAlbin’s picture

Version: 6.x-2.2 » 6.x-2.x-dev
FileSize
1.83 KB

I spent some time looking at this and I think this is a core bug. I'm pulling the active trail data directly from menu_tree_page_data().

I also compared a menu_block for the primary links menu with a standard core "primary links" block and they show the exact same behavior. If two or more menu links point to the same path, only one of them gets recognized as being in the active trail. Can you guys confirm that core menu's blocks work the same as menu_block's blocks?

I even tried the attached patch, but it didn't seem to help any.

BarisW’s picture

Subscribing. Same problem with for example the FAQ module and two languages. www.site.com/faq works, en.site.com/faq doesn't. I agre with John that this is a core issue, but it would be great if Menu Block could hack a way around this bug :)

emdalton’s picture

We just started having this problem with the latest update (6.x-2.3). Prior to that (6.x-2.2) we were able to have multiple menu blocks appear on the same page if that page appeared in all the menus. In our case, we aren't using multilingual pages, we just have several pages that need to appear in more than one menu. I didn't change Drupal Core at the same time-- in both situations we were using D6.16. Please let me know how I can help troubleshoot this problem.

bedlam’s picture

subscribe

manmohandream’s picture

I am facing somewhat different issue.two menu items on primary link points to same link but the argument passed is different.Due to this both links become active whenever anyone of two is clicked.
Any solution for this.
Thanks

tobiberlin’s picture

subscribe. The same issue here when I point with two items to one view on a multilingual page where the first item links to this view with an English label and the second with a German label. It seems that the second items causes the problem although German is the default language (regarded to some ideas above). So if I click on the second item OR I change the language while showing the view in English, the menu block disappears.

# Edit #

I looked at http://drupal.org/node/398888#comment-2388722 but for me this is not the problem. My menu has the structure

- Parent item 1
- sub item 1
- sub item 2

- Parent item 2
- sub item 1
- sub item 2

Where Parent item always links to the same node (!) as its sub item 1 - both items are shown correctly as active and the menu block is still shown. The first item block or parent item 1 is just shown when the language is English, the second when the language is German. Now the first sub item 2 (of parent item 1) and the second sub item 2 (of parent item 2) link to the same view labelled with their language. If I click on first sub item 2 the view is shown correctly in English. when I change the language or I click on the second sub item 2 of parent item 2 the menu block disappears.

jmseigneur’s picture

Subscribing

isaachorton’s picture

im having this issue as well.
Using the domain access module and multiple menu block items pointing to the same node.
The Menu Block will not show!

Solution anyone?

This is turning into a major issue for me.

isaachorton’s picture

Update:
Using the node symlinks module does NOT fix this problem
Before I was adding the alias to menus that points to the same destination, but here you add it via the node.
http://drupal.org/project/nodesymlinks

dealancer’s picture

subscribing, but solution #25 doesn't work for me

dealancer’s picture

It seems the problem in menu_tree_page_data - it does not return full tree.

Me menu structure

Primary links:
-About (en)
-- Contact (en)
-- Page 1 (en)
-- Views (en)
-- Page 2 (en)

-About (de)
-- Contact (de)
-- Page 1 (de)
-- Views (de)
-- Page 2 (de)

While wieing the Page 1 or Page 2 Menu Block is shown. When viewing Contact(de) or Views (de) it not happens. If I delete from menu Contact (en) and Views (en) then it will be shown on those pages.

dealancer’s picture

This bugs happens with everything which has the same path expect a nodes. Menu block uses menu_tree_page_data(...) to build a trail to the node.

For the menu_tree_page_data(...) there is no difference between 'contact' and 'de/contact' because it is pointing at he same page 'contact'. It returns only the first occurrence of that path from the table (In my case this is English menu) and build active trail to the page. Hence we've got trail to the 'conact' but not for 'de/contact', so this trail will be cut of by Menu Block module as improper.

The only working way I've found is to patch menu_tree_page_data (...), which is located in /included/menu.inc. My patch is attached.

dealancer’s picture

probably i11nmenu should provide similar and patched function and it should be used in Menu Block and others module.

jmseigneur’s picture

#28 patch does not seem to work on my side. Works in default language but not in other languages. Menu Block appears in default language but not in other languages.

dealancer’s picture

jmseigneur,
Have you tries to clear cache?
What is you menu structure?

jmseigneur’s picture

Yes the cache has been cleared without effect. The primary-links is used as the main menu. In this menu there are links in French the default language and English. A Menu Block is linked to this menu, displays the sub-menu items of the selected item of the main menu in French, the sub-menu items in English do not appear even after your patch.

dealancer’s picture

jmseigneur, If the parent menu is French, it won't display English sub-items, even if the current menu is English. Try to set parent menu language-neutral, or use menu structure as in #27/

askibinski’s picture

Check out this related core issue: #609542: Active trail isn't set on all menu items pointing to the current path and patch at #12 which I believe might also fix this problem. (though it is a core patch for a core bug).

stockliasteroid’s picture

I applied the patch mentioned in #34. While active-trail is now correctly set on the multiple menu items that the node is linked to under, the menu block still doesn't work correctly... I'm going to continue to look into this.

C. Lee’s picture

Here's my patch. It solves the problem when the duplicate paths are for different languages.

C. Lee’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev

I forgot to change the version to the latest. The above patch is for 7.x-3.x-dev.

complete’s picture

Man this solved it! Thank you! Works as a charm. Just patched the custom_menu_active_trail.inc file and cleared the cache, the problem is gone.

jmones’s picture

subscribe

Argus’s picture

Status: Active » Needs review

#36 needs a bit more review

conspirolog’s picture

#36 I confirm that this solves subj. English-Russian. Works great, no side effects for 2 days of active menu creation-moving-deleting etc.

Ludo.R’s picture

I have the same issue here using 7.x-2.2

Patch #36 works well for me!

peaton’s picture

I'm having the same problem described in the title of this issue "Menu Block does not work with menu items pointing to the same destination" but not for a multilingual site. I have a nodes that need to appear in two or more places of the menu and point to the same destination but menu block does not show the submenu correctly.

However, the patch in #36 only works with the internationalization issue.

Does anyone have a patch that addresses the problem for non-multilingual situations?

Thanks.

mostou’s picture

Patch in #36 works for me as well with a similar issue.

However this patch is dependant on the core workaround for this issue drupal.org/node/942782. Since this issue is fixed the core workaround will most likely be outphased soon (see http://drupal.org/node/1393204). Unless the workaround can be kept due to this issue http://drupal.org/node/609542, that is as far as I understand the core issue the patch in #36 is solving in Menu Block.
-----
Edit:
The core issue #609542 seems to be solved in Drupal 7.10 and i18n 7.x-1.2 (after a quick test). So patch in #36 may be unnecessary when the core workaround is removed (#1393204). Can other confirm this?

jimahuja’s picture

#43
I am having the same issue as mentioned in #43.

As per my reviews i found that the issue is when Drupal find the existence of first occurrence of link it stops finding the existence that if there is another link available for that node or not.

e.g. if i have NODE having 2 links in different menus, only menu with 'menu_name' coming first alphabetically is considered. say i have node/123 in menu_name = 'mennu-abc' and in menu_name = 'menu-xyz' so drupal always pick 'menu-abc' and stops looking of another occurrence of it. and hence, 'menu-abc' link will work fine with "Menu Block" but will not work for 'menu-xyz'.

Any Solutions for this issue?

jimahuja’s picture

Please check #45
I am having same issue

mostou’s picture

Patch in #36 will no longer work due to http://drupal.org/node/1425342 - the file custom_menu_active_trail.inc is removed. I still have the described issue though, because I can no longer apply patch 36 with the latest version of Menu Block 7.x-2.3

This may now only be a core issue, since the workaround file custom_menu_active_trail.inc is no longer used by Menu Block. Can anyone with a more technical insight confirm this?

Possible duplicate: http://drupal.org/node/609542

mostou’s picture

Status: Needs review » Closed (duplicate)

Due to #1425342: Drupal core upgrade from 7.10 to 7.12 causes menu block to fail this is no longer a Menu Block issue but an i18n issue. Duplicate issue here:
#1351678: Follow menu_link_get_preferred active trail handling for custom menus

The patch in the duplicate issue has been committed to i18n.

This issue should be solved with Drupal 7.12 + i18n 7.x-1.4 (+ Menu Block 7.x-2.3). If you still experience issues try and clear the cache.

KhaledBlah’s picture

I had the same problem and I used http://drupal.org/project/nodesymlinks to get rid of it. NodeSymlinks will create "menu aliases" so that you can point to the same content in different menus with unique breadcrumb, trail and even URL.

yang_yi_cn’s picture

just an update, I believe this issue is related to all custom menus, it just looks like happen when "menu items pointing to the same destination" because normally the 1st menu item is in the main menu and the 2nd menu item is in a custom menu.

I created a core issue at #1710744: Custom menus never receive an active trail (but system menu does).

cindytwilliams made their first commit to this issue’s fork.