Fixing start level in menu widget

When checking the Show Full Menu option
This commit is contained in:
Sebastien Ros
2013-10-10 15:41:37 -07:00
parent 4758056403
commit 96cd45fdae
2 changed files with 21 additions and 20 deletions

View File

@@ -115,21 +115,24 @@ namespace Orchard.Core.Navigation.Drivers {
else {
var topLevelItems = menuItems.ToList();
// should the menu be filtered on the currently displayed page ?
if (!part.ShowFullMenu) {
// apply start level by pushing children as top level items. When the start level is
// greater than 1 (ie. below the top level), only menu items along the selected path
// will be displayed.
for (var i = 0; topLevelItems.Any() && i < part.StartLevel - 1; i++) {
var temp = new List<MenuItem>();
if (selectedPath != null) {
topLevelItems = topLevelItems.Intersect(selectedPath.Where(x => x.Selected)).ToList();
foreach (var menuItem in topLevelItems) {
temp.AddRange(menuItem.Items);
}
// apply start level by pushing children as top level items. When the start level is
// greater than 1 (ie. below the top level), only menu items along the selected path
// will be displayed.
for (var i = 0; topLevelItems.Any() && i < part.StartLevel - 1; i++) {
var temp = new List<MenuItem>();
// should the menu be filtered on the currently displayed page ?
if (part.ShowFullMenu) {
foreach (var menuItem in topLevelItems) {
temp.AddRange(menuItem.Items);
}
topLevelItems = temp;
}
else if (selectedPath != null) {
topLevelItems = topLevelItems.Intersect(selectedPath.Where(x => x.Selected)).ToList();
foreach (var menuItem in topLevelItems) {
temp.AddRange(menuItem.Items);
}
}
topLevelItems = temp;
}
// limit the number of levels to display (down from and including the start level)

View File

@@ -44,10 +44,8 @@
</fieldset>
</div>
<div data-controllerid="@Html.FieldIdFor(m => m.Breadcrumb)">
<fieldset>
@Html.EditorFor(m => m.ShowFullMenu)
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.ShowFullMenu)">@T("No filter on selected page")</label>
<span class="hint">@T("Check for the menu to be display without filtering the selected current page.")</span>
</fieldset>
</div>
<fieldset>
@Html.EditorFor(m => m.ShowFullMenu)
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.ShowFullMenu)">@T("No filter on selected page")</label>
<span class="hint">@T("Check for the menu to be display without filtering the selected current page.")</span>
</fieldset>