#18977: Fixing tab rendering with query strings

Work Item: 18977

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-10-02 10:50:14 -07:00
parent 9cc218aa0e
commit 21dd00d46c
2 changed files with 22 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.DisplayManagement;
using Orchard.Mvc.Filters;
using Orchard.UI.Admin;
@@ -35,8 +36,17 @@ namespace Orchard.UI.Navigation {
IEnumerable<MenuItem> menuItems = _navigationManager.BuildMenu(menuName);
// adding query string parameters
var routeData = new RouteValueDictionary(filterContext.RouteData.Values);
var queryString = workContext.HttpContext.Request.QueryString;
if (queryString != null) {
foreach (var key in from string key in queryString.Keys where key != null && !routeData.ContainsKey(key) let value = queryString[key] select key) {
routeData[key] = queryString[key];
}
}
// Set the currently selected path
Stack<MenuItem> selectedPath = NavigationHelper.SetSelectedPath(menuItems, filterContext.RouteData);
Stack<MenuItem> selectedPath = NavigationHelper.SetSelectedPath(menuItems, routeData);
// Populate main nav
dynamic menuShape = _shapeFactory.Menu().MenuName(menuName);

View File

@@ -67,6 +67,16 @@ namespace Orchard.UI.Navigation {
/// <param name="currentRouteData">The current route data.</param>
/// <returns>A stack with the selection path being the last node the currently selected one.</returns>
public static Stack<MenuItem> SetSelectedPath(IEnumerable<MenuItem> menuItems, RouteData currentRouteData) {
return SetSelectedPath(menuItems, currentRouteData.Values);
}
/// <summary>
/// Identifies the currently selected path, starting from the selected node.
/// </summary>
/// <param name="menuItems">All the menuitems in the navigation menu.</param>
/// <param name="currentRouteData">The current route data.</param>
/// <returns>A stack with the selection path being the last node the currently selected one.</returns>
public static Stack<MenuItem> SetSelectedPath(IEnumerable<MenuItem> menuItems, RouteValueDictionary currentRouteData) {
if (menuItems == null)
return null;
@@ -78,7 +88,7 @@ namespace Orchard.UI.Navigation {
return selectedPath;
}
if (RouteMatches(menuItem.RouteValues, currentRouteData.Values)) {
if (RouteMatches(menuItem.RouteValues, currentRouteData)) {
menuItem.Selected = true;
selectedPath = new Stack<MenuItem>();