mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding ContentItemMetadata route values for widgets, blogs and blog posts
- also removing the default (Core.Contents specific) metadata from Orchard.ContentManagement.ContentItemMetadata work items: 16683, 16791 --HG-- branch : dev
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using JetBrains.Annotations;
|
||||
using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
using Orchard.Widgets.Models;
|
||||
@@ -9,5 +11,32 @@ namespace Orchard.Widgets.Handlers {
|
||||
public WidgetPartHandler(IRepository<WidgetPartRecord> widgetsRepository) {
|
||||
Filters.Add(StorageFilter.For(widgetsRepository));
|
||||
}
|
||||
|
||||
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||
var widget = context.ContentItem.As<WidgetPart>();
|
||||
|
||||
if (widget == null)
|
||||
return;
|
||||
|
||||
// create needs to go through the add widget flow (index -> [select layer -> ] add [widget type] to layer)
|
||||
context.Metadata.CreateRouteValues = new RouteValueDictionary {
|
||||
{"Area", "Orchard.Widgets"},
|
||||
{"Controller", "Admin"},
|
||||
{"Action", "Index"}
|
||||
};
|
||||
context.Metadata.EditorRouteValues = new RouteValueDictionary {
|
||||
{"Area", "Orchard.Widgets"},
|
||||
{"Controller", "Admin"},
|
||||
{"Action", "EditWidget"},
|
||||
{"Id", context.ContentItem.Id}
|
||||
};
|
||||
// remove goes through edit widget...
|
||||
context.Metadata.RemoveRouteValues = new RouteValueDictionary {
|
||||
{"Area", "Orchard.Widgets"},
|
||||
{"Controller", "Admin"},
|
||||
{"Action", "EditWidget"},
|
||||
{"Id", context.ContentItem.Id}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user