diff --git a/src/Extensions/SiteTreeExtension.php b/src/Extensions/SiteTreeExtension.php index 743017d..e22d750 100755 --- a/src/Extensions/SiteTreeExtension.php +++ b/src/Extensions/SiteTreeExtension.php @@ -50,7 +50,7 @@ class SiteTreeExtension extends DataExtension { $obj = $this->owner; - if($obj->DisableSidebar) { + if ($obj->DisableSidebar) { return false; } @@ -58,19 +58,16 @@ class SiteTreeExtension extends DataExtension if (!$area) { return true; } + $els = $area->Elements(); if (!$els) { return true; } - $els = $els->find('ClassName', SidebarElement::class); - if (!$els) { + $sidebarEl = $els->find('ClassName', SidebarElement::class)?->first(); + if ($sidebarEl) { return true; } - if ($els->first()) { - return false; - } - if ($obj->SideBarContent) { return true; } @@ -108,7 +105,7 @@ class SiteTreeExtension extends DataExtension return $this->_cached['summary' . $wordsToDisplay]; } - if(!method_exists($obj, 'ElementalArea')) { + if (!method_exists($obj, 'ElementalArea')) { return; }