diff --git a/src/Orchard/UI/Navigation/NavigationHelper.cs b/src/Orchard/UI/Navigation/NavigationHelper.cs index b6cb0faa8..2ab551c97 100644 --- a/src/Orchard/UI/Navigation/NavigationHelper.cs +++ b/src/Orchard/UI/Navigation/NavigationHelper.cs @@ -84,6 +84,12 @@ namespace Orchard.UI.Navigation { var path = SetSelectedPath(menuItems, currentRequest, currentRouteData, false) ?? SetSelectedPath(menuItems, currentRequest, currentRouteData, true); + if(path != null) { + foreach(var menuItem in path) { + menuItem.Selected = true; + } + } + return path; } @@ -96,12 +102,17 @@ namespace Orchard.UI.Navigation { /// Should compare raw string URLs instead of route data. /// A stack with the selection path being the last node the currently selected one. private static Stack SetSelectedPath(IEnumerable menuItems, HttpRequestBase currentRequest, RouteValueDictionary currentRouteData, bool compareUrls) { + var selectedPaths = new List>(); foreach (MenuItem menuItem in menuItems) { Stack selectedPath = SetSelectedPath(menuItem.Items, currentRequest, currentRouteData, compareUrls); if (selectedPath != null) { - menuItem.Selected = true; selectedPath.Push(menuItem); - return selectedPath; + if (compareUrls) { + selectedPaths.Add(selectedPath); + } + else { + return selectedPath; + } } // compare route values (if any) first @@ -122,15 +133,19 @@ namespace Orchard.UI.Navigation { } if (match) { - menuItem.Selected = true; - selectedPath = new Stack(); selectedPath.Push(menuItem); - return selectedPath; + + if (compareUrls) { + selectedPaths.Add(selectedPath); + } + else { + return selectedPath; + } } } - return null; + return selectedPaths.OrderByDescending(p => p.First().Href.Split('/').Length).FirstOrDefault(); } ///