Hello, first sorry for my bad english, i have made a little patch in menu.inc which allow menu items with same path to be created in each language, here's an example of this usage :

- You have drupal with i18n and panels module enabled
- You have two language enabled in your website (english and french by example)
- You create a content translated in all languages of your website
- You create a panel page with the url 'panel' and add the node you created in the step above (in default language to let panels choose the translated version of the node in current language)
- Now, if you go to 'panel', you will have the panel page with the node inside in the good translation
- You create another content translated in all languages (with menu item for each translation in primary-links) => i call it 'parent'
- You add for each menu item of content 'parent' a menu item which points to 'panel' and in the language of 'parent' menu item
- Now, in the primary-links, you have :

+ parent (in english, points to node parent in english)
-+ panel (in english, points to panel)
+ parent (in french, points to node parent in french)
-+ panel (in french, points to panel)

- Now you have the choice : you can set source of secondary-links to primary-links and show secondary-links in your theme OR you can create (with the module 'Menu Block') a menu block of primary-links with level 2 to show child items)

- So you have for each language the item 'parent' with the sub-item 'panel'
- When you click on 'parent' item (in any language), you will see the panel sub item as expected
- If you click on the 'panel' sub item (in english language if the content has been created in english language first), you will see the panel and menu is always ok
- BUT if you click on the 'panel' sub item in other language (not the first created), the sub item will disappear

It's because menu functions doesn't see the difference between menu items with same path and different languages (it doesn't care about language)
That cause also problems with breadcrumb when you need similary structure.

So i have write a little patch in menu.inc (in menu_tree_page_data function) :

Replace

  static $tree = array();

by :

  global $language;
  static $tree = array();

Then replace :

  // Generate a cache ID (cid) specific for this page.
  $cid = 'links:'. $menu_name .':page-cid:'. $item['href'] .':'. (int)$item['access'];

by :

  // Generate a cache ID (cid) specific for this page.
  $cid = 'links:'. $menu_name .':page-cid:'. $item['href'] .':'. (int)$item['access'] . ':langcode:' . $language->language;

Then replace :

  $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path IN (". $placeholders .")", $args));

by :

  if ($result = db_query("SELECT options, p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path IN (". $placeholders .")", $args)) {	  
    while ($link = db_fetch_array($result)) {
      // Get options array
      $options = unserialize($link['options']);
      
      // If langcode is current language or no language, add this parent
      if ((!(isset($options['langcode']))) || ($options['langcode'] == $language->language)) {
        // Remove options in array
        unset($link['options']);
	
        // Set parent
        $parents = $link;
        
        break;
      }
    }
  }

Then replace (maybe not necessary) :

  $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root']));

by :

  if ($result = db_query("SELECT options, p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root'])) {
    while ($link = db_fetch_array($result)) {
      // Get options array
      $options = unserialize($link['options']);
      
      // If langcode is current language or no language, add this parent
      if ((!(isset($options['langcode']))) || ($options['langcode'] == $language->language)) {
        // Remove options in array
        unset($link['options']);
        
        // Set parent
        $parents = $link;
	
        break;
      }
    }
  }

This patch needs review but normally it's ok, it doesn't cause problems with website without multilingual support.

Comments

chaugi’s picture

I have had same issue, why this patch is not included in drupal core update?!

dddave’s picture

Status: Needs review » Needs work

This would need a proper patch file to review. http://drupal.org/patch/create

And it should be tested with the latest builds of Drupal 6, i18n and Panels. Does this problem still exist?

AND: I don't understand the problem totally as I am not too invested in this issue (just stumbled upon this issue report) but I suspect that Panels provides a workable solution already.

aekarpenko’s picture

It's not just language related. Drupal menus fail if you [have] any two menus point to the same node, whether they are within the same menu, or in completely different menus. See: http://drupal.org/node/609542

chaugi’s picture

StatusFileSize
new39.15 KB

@dddave

The problem still exists. It is hard to describe, but as in our country we mainly create only multilingual sites the problem arises from time to time :( The reason why this problem happens is probably because of the paths.
For e.g. each node has internal path node/nid. But for example, views and panels has no nid they have just path for all languages. And it appears that if you create panel with path like for e.g "secondary" and place this as child of primary links item and in settings specify "Source for the secondary links: Primary links" you will see that going to this menu item, menu item will be lost.

I have a dump of Files and DB of example, which recreates this situation, so you won't need to create it by yourself.
Drupal 6.19
Panles 3.8
Ctools 1.8
i18n 1.7
All in one files (2.53 MB): http://www.rasayana.lv/test.zip
DB (173 KB): http://www.rasayana.lv/test-db.zip

If you go to:
http://localhost/test/ru/secondary
http://localhost/test/lv/secondary
menu Item will be lost

P.S. I have tried to apply modifications as described above but this does not solve the problem, so this "patch" does not work.

dddave’s picture

Title: Patch to allows menu items with same path in different languages » Patch to allow menu items with same path in different languages
Version: 6.11 » 6.19

Ok, I guess I understand the problem now. Anyways: As long as nobody can provide a killer patch for this nothing will happen.

Has anyone checked if the problem persists in D7?

chaugi’s picture

Version: 6.19 » 7.0-beta3
StatusFileSize
new37.46 KB

1. With D7 is a bit different. Menu does not disappear.
But if your language (in this example) is Latvian or English and you are on appropriate language node, Sample LV (Latvian language) and you click on Panels LV (Sample LV submenu item, points to Panel page with url: /secondary, containing translated node), last menu item is activated (Sample RU), but Sample LV should be active.

Drupal 7, beta 3
Ctools 1.0-alpha1
Panels 3.0-alpha1

All in one files (4.00 MB): http://www.rasayana.lv/test2.zip
DB (242 KB): http://www.rasayana.lv/test2-db.zip

2. One more interesting thing with menu. If my language is Latvian (see URL), but I am on node with different language, link item showing current language is inactive on language switch block.

chaugi’s picture

StatusFileSize
new14.27 KB

One more bug in Drupal 7 beta3. In case in "Site information" I set Drupal default page to one translated node, e.g. Sample EN, and on front page switch the language from English to Russian nothing is going to be changes, neither translation nor active tab (in Bartik theme)

chaugi’s picture

The problem still exists. It is hard to describe, but as in our country we mainly create only multilingual sites the problem arises from time to time :( The reason why this problem happens is probably because of the paths.
For e.g. each node has internal path node/nid. But for example, views and panels has no nid they have just path for all languages. And it appears that if you create panel with path like for e.g "secondary" and place this as child of primary links item and in settings specify "Source for the secondary links: Primary links" you will see that going to this menu item, menu item will be lost.

This issue is resolved using the following patch:
http://drupal.org/node/609542#comment-3425724
I have tested by myself on Drupal 6.19. Should be included in core.

chaugi’s picture

One more bug in Drupal 7 beta3. In case in "Site information" I set Drupal default page to one translated node, e.g. Sample EN, and on front page switch the language from English to Russian nothing is going to be changes, neither translation nor active tab (in Bartik theme)

I there the way to speed up this problem solution, should I post somewhere else?!

dddave’s picture

The only way to speed things up is to provide a patch.

rvilar’s picture

Version: 7.0-beta3 » 7.x-dev

Subscribing

NROTC_Webmaster’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs work » Needs review
StatusFileSize
new4.55 KB

I think this has already been fixed in D7/D8 but here is a patch for D6 based on the code listed.

Status: Needs review » Needs work

The last submitted patch, menu-language-12-D6.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

catch’s picture

Status: Needs work » Closed (outdated)
Issue tags: +Bug Smash Initiative

Based on #12, closing this as outdated.