mirror of
https://github.com/silverstripe/silverstripe-widgets
synced 2024-09-28 20:29:09 +02:00
Support widget forms with InheritSidebar
Currently the system assumes that if a widget ends up at "handleWidget" that the widget resides on the current page. This patch checks if we are inheriting the sidebar and if so finds the top level page with the widget.
This commit is contained in:
parent
c332a6ab8b
commit
ff0178330a
@ -29,9 +29,15 @@ class WidgetContentControllerExtension extends Extension {
|
|||||||
$SQL_id = $this->owner->getRequest()->param('ID');
|
$SQL_id = $this->owner->getRequest()->param('ID');
|
||||||
if(!$SQL_id) return false;
|
if(!$SQL_id) return false;
|
||||||
|
|
||||||
|
/** @var SiteTree $widgetOwner */
|
||||||
|
$widgetOwner = $this->owner->data();
|
||||||
|
while($widgetOwner->InheritSideBar && $widgetOwner->Parent()->exists()){
|
||||||
|
$widgetOwner = $widgetOwner->Parent();
|
||||||
|
}
|
||||||
|
|
||||||
// find WidgetArea relations
|
// find WidgetArea relations
|
||||||
$widgetAreaRelations = array();
|
$widgetAreaRelations = array();
|
||||||
$hasOnes = $this->owner->data()->has_one();
|
$hasOnes = $widgetOwner->has_one();
|
||||||
|
|
||||||
if(!$hasOnes) {
|
if(!$hasOnes) {
|
||||||
return false;
|
return false;
|
||||||
@ -51,7 +57,8 @@ class WidgetContentControllerExtension extends Extension {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$widget = $this->owner->data()->$widgetAreaRelation()->Widgets(
|
|
||||||
|
$widget = $widgetOwner->$widgetAreaRelation()->Widgets(
|
||||||
sprintf('"Widget"."ID" = %d', $SQL_id)
|
sprintf('"Widget"."ID" = %d', $SQL_id)
|
||||||
)->First();
|
)->First();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user