mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
A couple improvements regarding navigation
- Blogs can be added to the main menu - Add permission checks to show/hide the menupart editors as needed - Remove the unnecessary root node "main menu" when building the main menu --HG-- branch : dev
This commit is contained in:
@@ -1,15 +1,30 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
[UsedImplicitly]
|
||||
public class MenuPartDriver : ContentPartDriver<MenuPart> {
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
|
||||
public MenuPartDriver(IAuthorizationService authorizationService) {
|
||||
_authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
public virtual IUser CurrentUser { get; set; }
|
||||
|
||||
protected override DriverResult Editor(MenuPart part) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
|
||||
return null;
|
||||
|
||||
return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location("primary", "9");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(MenuPart part, IUpdateModel updater) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
|
||||
return null;
|
||||
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location("primary", "9");
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ namespace Orchard.Core.Navigation.Models {
|
||||
[UsedImplicitly]
|
||||
public class MenuPartHandler : ContentHandler {
|
||||
public MenuPartHandler(IRepository<MenuPartRecord> menuPartRepository) {
|
||||
Filters.Add(new ActivatingFilter<MenuPart>("blogpost"));
|
||||
Filters.Add(new ActivatingFilter<MenuPart>("blog"));
|
||||
Filters.Add(new ActivatingFilter<MenuPart>("page"));
|
||||
Filters.Add(StorageFilter.For(menuPartRepository));
|
||||
|
||||
|
@@ -19,8 +19,7 @@ namespace Orchard.Core.Navigation.Services {
|
||||
foreach (var menuPart in menuParts) {
|
||||
if (menuPart != null ) {
|
||||
MenuPart part = menuPart;
|
||||
builder.Add("main menu", "1",
|
||||
menu => menu
|
||||
builder.Add(menu => menu
|
||||
.Add(part.MenuText, part.MenuPosition));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user