mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-01 19:06:11 +08:00
Adding new Show Full Menu option in menu widget
Adding a way to display a menu without filtering its items base on the currently displayed page.
This commit is contained in:
parent
46c7ea5a92
commit
964d56df70
@ -115,18 +115,21 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
else {
|
||||
var topLevelItems = menuItems.ToList();
|
||||
|
||||
// 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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
topLevelItems = temp;
|
||||
}
|
||||
topLevelItems = temp;
|
||||
}
|
||||
|
||||
// limit the number of levels to display (down from and including the start level)
|
||||
@ -165,6 +168,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
Breadcrumb = part.Breadcrumb,
|
||||
AddCurrentPage = part.AddCurrentPage,
|
||||
AddHomePage = part.AddHomePage,
|
||||
ShowFullMenu = part.ShowFullMenu,
|
||||
Menus = _menuService.GetMenus(),
|
||||
};
|
||||
|
||||
@ -181,6 +185,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
part.Breadcrumb = model.Breadcrumb;
|
||||
part.AddHomePage = model.AddHomePage;
|
||||
part.AddCurrentPage = model.AddCurrentPage;
|
||||
part.ShowFullMenu = model.ShowFullMenu;
|
||||
part.Menu = _contentManager.Get(model.CurrentMenuId).Record;
|
||||
}
|
||||
|
||||
@ -193,6 +198,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
context.ImportAttribute(part.PartDefinition.Name, "Breadcrumb", x => part.Breadcrumb = Convert.ToBoolean(x));
|
||||
context.ImportAttribute(part.PartDefinition.Name, "AddCurrentPage", x => part.AddCurrentPage = Convert.ToBoolean(x));
|
||||
context.ImportAttribute(part.PartDefinition.Name, "AddHomePage", x => part.AddHomePage = Convert.ToBoolean(x));
|
||||
context.ImportAttribute(part.PartDefinition.Name, "ShowFullMenu", x => part.ShowFullMenu = Convert.ToBoolean(x));
|
||||
|
||||
context.ImportAttribute(part.PartDefinition.Name, "Menu", x => part.Menu = context.GetItemFromSession(x).Record);
|
||||
}
|
||||
@ -206,6 +212,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Breadcrumb", part.Breadcrumb);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("AddCurrentPage", part.AddCurrentPage);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("AddHomePage", part.AddHomePage);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("ShowFullMenu", part.ShowFullMenu);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
@ -32,5 +33,10 @@ namespace Orchard.Core.Navigation.Models {
|
||||
get { return Record.Menu; }
|
||||
set { Record.Menu = value; }
|
||||
}
|
||||
|
||||
public bool ShowFullMenu {
|
||||
get { return bool.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("ShowFullMenu") ?? "false"); }
|
||||
set { this.As<InfosetPart>().Set<MenuWidgetPart>("ShowFullMenu", value.ToString()); }
|
||||
}
|
||||
}
|
||||
}
|
@ -11,5 +11,6 @@ namespace Orchard.Core.Navigation.ViewModels {
|
||||
public bool Breadcrumb { get; set; }
|
||||
public bool AddHomePage { get; set; }
|
||||
public bool AddCurrentPage { get; set; }
|
||||
public bool ShowFullMenu { get; set; }
|
||||
}
|
||||
}
|
@ -42,4 +42,12 @@
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AddCurrentPage)">@T("Add the current content item as the last element")</label>
|
||||
<span class="hint">@T("Check to render the current content item as the last element.")</span>
|
||||
</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>
|
Loading…
Reference in New Issue
Block a user