mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-27 04:19:04 +08:00
Added LayoutSaving call to context in WidgetElementHarvester to properly update the container of widgets. (#8534)
This commit is contained in:
committed by
GitHub
parent
ea3c7d89b1
commit
88a79cb768
@@ -47,11 +47,30 @@ namespace Orchard.Widgets.Layouts.Providers {
|
||||
Importing = ImportElement,
|
||||
StateBag = new Dictionary<string, object> {
|
||||
{ "ContentTypeName", contentTypeDefinition.Name }
|
||||
}
|
||||
},
|
||||
LayoutSaving = LayoutSaving
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void LayoutSaving(ElementSavingContext context) {
|
||||
// I need to save the widget element container.
|
||||
var element = (Widget)context.Element;
|
||||
if (element == null) {
|
||||
return;
|
||||
}
|
||||
var widgetId = element.WidgetId;
|
||||
var widget = _contentManager.Value.Get(widgetId.Value, VersionOptions.Latest);
|
||||
if (widget == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var commonPart = widget.As<ICommonPart>();
|
||||
if (commonPart != null) {
|
||||
commonPart.Container = context.Content;
|
||||
}
|
||||
}
|
||||
|
||||
private void Displaying(ElementDisplayingContext context) {
|
||||
var contentTypeName = (string)context.Element.Descriptor.StateBag["ContentTypeName"];
|
||||
var element = (Widget)context.Element;
|
||||
|
||||
Reference in New Issue
Block a user