3

Resolved

Menu Widget Levels to display it is broken

description

I expect that "Levels to display" setting must limit the displayed menu levels. Instead, it show only that level. If my assumption is correct, the fix could be this code (MenuWidgetPartDriver.cs):
                    //// apply display level ?
                    //if(part.Levels > 0) {
                    //    var current = topLevelItems.ToList();
                    //    for (int j=1; j < part.Levels; j++ ) {
                    //        var temp = new List<MenuItem>();
                    //        foreach (var menuItem in current) {
                    //            temp.AddRange(menuItem.Items);
                    //        }
                    //        current = temp;
                    //    }

                    //    topLevelItems = current;

                    //    // cut the sub-levels of any selected menu item
                    //    foreach (var menuItem in topLevelItems) {
                    //        menuItem.Items = Enumerable.Empty<MenuItem>();
                    //    }                

                    //}

                    // apply display level ?
                    if (part.Levels > 0)
                    {
                        var current = topLevelItems.ToList();
                        for (int j = 1; j < part.Levels; j++)
                        {
                            var temp = new List<MenuItem>();
                            foreach (var menuItem in current)
                            {
                                temp.AddRange(menuItem.Items);
                            }
                            current = temp;
                        }

                        // cut the sub-levels of any selected menu item
                        foreach (var menuItem in current)
                        {
                            menuItem.Items = Enumerable.Empty<MenuItem>();
                        }

                    }

comments

aadnesgaard wrote Jan 10, 2013 at 11:24 PM

This seems to fix the issue.

aadnesgaard wrote Jan 11, 2013 at 4:24 PM

Further investigation shows this introduces another issue with breadcrumbs. If you have a menu set as a breadcrumb on any zone, a menu will render on the root page with no styles.

This can be corrected by returning null if the part is a breadcrumb with no selected path:
var selectedPath = NavigationHelper.SetSelectedPath(menuItems, routeData); //Line 79

//Add this
if (part.Breadcrumb && selectedPath == null) {
    return null;
}

juFo wrote Jun 12, 2013 at 12:22 PM

In 1.6.1 I have also lots of problems with the navigation that it shows wrong menu items or sometimes completely dissapears.
It is holding me back to use orchard.