mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 19:34:40 +08:00
@@ -11,13 +11,5 @@ namespace Orchard.Core.Navigation.Handlers {
|
||||
Filters.Add(new ActivatingFilter<MenuItemPart>("MenuItem"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
}
|
||||
|
||||
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||
var part = context.ContentItem.As<MenuItemPart>();
|
||||
|
||||
if (part != null) {
|
||||
context.Metadata.Identity.Add("MenuItem.Url", part.Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,12 +8,33 @@ using Orchard.Data;
|
||||
namespace Orchard.Core.Navigation.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class MenuPartHandler : ContentHandler {
|
||||
public MenuPartHandler(IRepository<MenuPartRecord> menuPartRepository) {
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public MenuPartHandler(
|
||||
IRepository<MenuPartRecord> menuPartRepository,
|
||||
IContentManager contentManager
|
||||
) {
|
||||
|
||||
_contentManager = contentManager;
|
||||
Filters.Add(StorageFilter.For(menuPartRepository));
|
||||
|
||||
OnInitializing<MenuPart>((ctx, x) => {
|
||||
x.MenuText = String.Empty;
|
||||
});
|
||||
|
||||
OnActivated<MenuPart>(PropertySetHandlers);
|
||||
}
|
||||
|
||||
protected static void PropertySetHandlers(ActivatedContentContext context, MenuPart menuPart) {
|
||||
menuPart.MenuField.Setter(menu => {
|
||||
menuPart.Record.MenuId = menu.ContentItem.Id;
|
||||
return menu;
|
||||
});
|
||||
}
|
||||
|
||||
protected void LazyLoadHandlers(MenuPart menuPart) {
|
||||
menuPart.MenuField.Loader(ctx =>
|
||||
_contentManager.Get(menuPart.Record.MenuId, menuPart.IsPublished() ? VersionOptions.Published : VersionOptions.Latest));
|
||||
}
|
||||
|
||||
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||
@@ -26,5 +47,6 @@ namespace Orchard.Core.Navigation.Handlers {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user