IMPR: Allow moving Sidebar into elements list

This commit is contained in:
Tony Air 2023-09-29 20:27:01 +02:00
parent 0019e3e6fd
commit c0cf1c72c1
1 changed files with 13 additions and 1 deletions

View File

@ -44,8 +44,20 @@ class SiteTreeExtension extends DataExtension
public function ShowSidebar()
{
$obj = $this->owner;
$area = $obj->ElementalArea();
if(!$area) {
return true;
}
$els = $area->Elements();
if(!$els) {
return true;
}
$els = $els->find('ClassName', SidebarElement::class);
if(!$els) {
return true;
}
if ($obj->ElementalArea()->Elements()->find('ClassName', SidebarElement::class)->first()) {
if ($els->first()) {
return false;
}