IMPR: Allow moving Sidebar into elements list

This commit is contained in:
Tony Air 2023-09-24 18:51:04 +02:00
parent bfdbf2dbfa
commit 0019e3e6fd
1 changed files with 23 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace A2nt\CMSNiceties\Extensions;
use A2nt\ElementalBasics\Elements\SidebarElement;
use SilverStripe\Forms\TextareaField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Forms\FieldList;
@ -40,6 +41,28 @@ class SiteTreeExtension extends DataExtension
}
}
public function ShowSidebar()
{
$obj = $this->owner;
if ($obj->ElementalArea()->Elements()->find('ClassName', SidebarElement::class)->first()) {
return false;
}
if ($obj->SideBarContent) {
return true;
}
if (method_exists($obj, 'SideBarView')) {
$view = $obj->SideBarView();
if ($view && $view->Widgets()->count()) {
return true;
}
}
return false;
}
public function onBeforeWrite()
{
parent::onBeforeWrite();