mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-23 13:22:08 +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,
|
Importing = ImportElement,
|
||||||
StateBag = new Dictionary<string, object> {
|
StateBag = new Dictionary<string, object> {
|
||||||
{ "ContentTypeName", contentTypeDefinition.Name }
|
{ "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) {
|
private void Displaying(ElementDisplayingContext context) {
|
||||||
var contentTypeName = (string)context.Element.Descriptor.StateBag["ContentTypeName"];
|
var contentTypeName = (string)context.Element.Descriptor.StateBag["ContentTypeName"];
|
||||||
var element = (Widget)context.Element;
|
var element = (Widget)context.Element;
|
||||||
|
|||||||
Reference in New Issue
Block a user