mirror of
https://github.com/silverstripe/silverstripe-widgets
synced 2024-10-22 15:05:54 +00:00
commit
d1586a5b5e
@ -47,6 +47,24 @@ class WidgetPageExtension extends DataExtension {
|
||||
return $this->owner->SideBar();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support Translatable so that we don't link WidgetAreas across translations
|
||||
|
Loading…
x
Reference in New Issue
Block a user