Navigation. Links with identical text not displayed


So, I create two absolutely identical Content Item Links (same name and same target content type), but shown only one of them. Probably this is fine, but same thing happens if this links placed at the different sub-menus.
Example, menu structure:
|--Home/About (Link Text: "About")
|--Projects/About (Link Text: "About")

I think in this case both menu items should be visible


j3ffb wrote Nov 12, 2012 at 11:28 PM

I came across this and added the following to the bottom of the Equals() method in Orchard/UI/Navigation/MenuItemComparer.cs
      if (!string.IsNullOrWhiteSpace(x.Position) && !string.IsNullOrWhiteSpace(y.Position)) {
           if (!string.Equals(x.Position, y.Position)) {
               return false;

pszmyd wrote Dec 12, 2012 at 6:20 PM

It's definitely a bug. There should be a check for parent menu item position inside MenuItemComparer. We still want to remove duplicates under a given parent, but not in the menu as a whole.

pszmyd wrote Dec 14, 2012 at 4:17 AM

@j3ffb Not quite. The actual fix should compare parent positions, because we still want to remove duplicated children items of a given parent. I'm on it, a fix should be there shortly (1.x branch).

pszmyd wrote Dec 14, 2012 at 4:22 AM

Fixed in changeset 1a5c61516874

pszmyd wrote Dec 14, 2012 at 8:56 PM

Fixed in changeset 3b2d1e68942d

manudea wrote Jun 2, 2013 at 4:30 PM

"We still want to remove duplicates under a given parent, but not in the menu as a whole."
Why do you want this? If I put 2 menus with same text on same menu it is my fault or my reason... why did you need to "correct" this in code?

BertrandLeRoy wrote Jun 3, 2013 at 8:12 AM

Please give the source of that quote.

pszmyd wrote Jun 3, 2013 at 9:02 AM

It's from the first comment of mine:) We do need to remove duplicates mostly because of the admin menu - different modules may (and they do) provide subtrees that need to be merged when rendering the final menu. Otherwise we'd end up having multiplied items. Example - let's say two modules want to add an item underneath "Foo" - one adds "Bar" and the other adds "Baz". Both need to provide a full subtree - "Foo" -> "Bar" and "Foo" -> "Baz" (respectively). Without removing duplicates you'd end up having two "Foo"s with one subitem each ("Bar" and "Baz"), but the desired output is one "Foo" with two subitems.

On the other hand, I agree with your point that user-created menus should be exempt from that duplicate-removal behavior, as there might be a need for duplicated items (although most of the time it smells like a bad navigation design). Right now the admin and user-provided menus are handled separately by different providers (INavigationProvider and IMenuProvider implementations) so it'd be possible to have different logic for either one.

sfmskywalker wrote Mar 28 at 1:28 AM

Fixed in changeset 3a315d3b485170feaefbdf026dbad2b40a6770d3

sfmskywalker wrote Mar 28 at 1:28 AM

Fixed in changeset 06625c20fd1b9874b3da7c78f75dcb97200ee612