751 Posts in 310 Topics by 289 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1524 Views |
-
Possible bug in the duplicating page and children functionality

5 February 2010 at 1:38pm
Hi there I have just a bug, but I dont know if its expected behavior. There is the following scenario.
Your page class has a widget area (which is the relation to that forum).
You have a holder page (inherits page) with lots of child (inherits page) pages. Then u duplicate the holder with all its childs. This means for me I create new pages, and it does create new pages. The problem is it does not create an WidgetAreas in the WidgetArea table --> for the new pages. It just refers to the page from which u have duplicated. So if you now change a widget in one holder page you change the widget in other holder page as well, and this is just not how I would expect it. I would like to change my widgets for every page how i need them and thats not possible if u duplicate in that way. Is there something I can do, maybe a setting to force the system to create new widgetAreas for the new pages .
Atm I need to do that manualy in the database and that is a bit pain in the ass (ups sorry).
Is that a bug or expected behavior ??
Thank you in advance.
-
Re: Possible bug in the duplicating page and children functionality

10 February 2010 at 12:40pm
what a shame no one was able to answer this simple question. I had a deeper look in the cms and sappire code. It turns out that the duplicate functions (one page or with children) ignore any relations. I mean it is principle fine to do so, but in case of a has_one relation with an widget area u run in trouble by just duplication the page table entry and keeping the widget area id. Duplication is atm not an option anymore because of this issue, what a shame.
I could hack the code and create with the duplication of a page on the fly widgetareas but this would require changes to the core, and I would like to avoid that. Is there a easy way to extend the sitetree methods.
Thx
Thomas
-
Re: Possible bug in the duplicating page and children functionality

23 February 2011 at 12:57pm
hi,
got the same issue. you are right there's no new WidgetArea-Item created.
maybe an overwrite of an parent-method could be the answer. something to do with "onBeforeWrite" or something like that...
what's the method that duplicates these pages? any guesses?
cheers
-
Re: Possible bug in the duplicating page and children functionality

18 January 2012 at 2:11am Last edited: 18 January 2012 2:25am
This was really annoying me also. Duplicating pages results in just referenced widgets, not duplicated widgets.
My solution is to extend the duplicate-function on Page class (page.php):
/**
* Duplicate this page, and make a copy of its Widgets (instead of copying the reference to it).
*
* @return Page
*/
public function duplicate() {
$oPage = parent::duplicate();
if($this->hasField("SidebarID") && ($this->getComponent("Sidebar"))) {
//duplicate the current widgetArea
$newWidgetArea = $this->getComponent("Sidebar")->duplicate();
//loop through all widgets linked to this wigetArea & connect them to the new WidgetArea
foreach($this->getComponent("Sidebar")->Items() as $oAreaWidget) {
$newWidget = $oAreaWidget->duplicate();
$newWidget->ParentID = $newWidgetArea->ID;
$newWidget->write();
}
//connect the new widgetArea to the duplicate page
$oPage->SidebarID = $newWidgetArea->ID;
}
return $oPage;
}Hopefully this helps someone else aswell...
| 1524 Views | ||
|
Page:
1
|
Go to Top |



