When I clone a layout, the widgets inside it aren't really cloned, but a reference to the original widget is saved.
This causes a breaking issue when editing or deleting the child widget, which gets edited or deleted across multiple layouts (because they have the same id).
Case scenario:
- Creation of Layout widget 1 (with id 1), with child widget 1 (with id 2)
- Cloning of Layout widget 1
- The cloned content is Layout widget 2 (id = 3), with child widget 1 inside it (id = 2!)
To avoid this problem, I need to edit the ImportElement routine in order to create a brand new widget (forcing its cloning) only when the original container is different from the clone container (this condition ensures it's a cloning operation and not a standard import).
The line of code I'm working on is:
|
var element = (Widget)context.Element; |
When I clone a layout, the widgets inside it aren't really cloned, but a reference to the original widget is saved.
This causes a breaking issue when editing or deleting the child widget, which gets edited or deleted across multiple layouts (because they have the same id).
Case scenario:
To avoid this problem, I need to edit the ImportElement routine in order to create a brand new widget (forcing its cloning) only when the original container is different from the clone container (this condition ensures it's a cloning operation and not a standard import).
The line of code I'm working on is:
Orchard/src/Orchard.Web/Modules/Orchard.Widgets/Layouts/Providers/WidgetElementHarvester.cs
Line 188 in 88a79cb