mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
IMPR: Allow moving Sidebar into elements list
This commit is contained in:
parent
bfdbf2dbfa
commit
0019e3e6fd
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user