mirror of
https://github.com/silverstripe/silverstripe-widgets
synced 2024-10-22 15:05:54 +00:00
FIX #58 on page duplicate
Fixing issue #58 where WidgetAreas end up being linked to multiple pages at once
This commit is contained in:
parent
c971289104
commit
d56c5398ac
@ -48,4 +48,22 @@ class WidgetPageExtension extends DataExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onBeforeDuplicate($duplicatePage) {
|
||||||
|
if($this->owner->hasField('SideBarID')) {
|
||||||
|
$sideBar = $this->owner->getComponent('SideBar');
|
||||||
|
$duplicateWidgetArea = $sideBar->duplicate();
|
||||||
|
|
||||||
|
foreach($sideBar->Items() as $originalWidget) {
|
||||||
|
$widget = $originalWidget->duplicate(false);
|
||||||
|
$widget->ParentID = $duplicateWidgetArea->ID;
|
||||||
|
$widget->write();
|
||||||
|
}
|
||||||
|
|
||||||
|
$duplicatePage->SideBarID = $duplicateWidgetArea->ID;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $duplicatePage;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user