IMPR: Allow to disable sidebar

This commit is contained in:
Tony Air 2024-06-28 20:27:46 +02:00
parent 425c236f5f
commit 03dba051bc
2 changed files with 7 additions and 2 deletions

View File

@ -8,6 +8,7 @@ use SilverStripe\Forms\LiteralField;
use SilverStripe\Widgets\Forms\WidgetAreaEditor; use SilverStripe\Widgets\Forms\WidgetAreaEditor;
use SilverStripe\Widgets\Model\Widget; use SilverStripe\Widgets\Model\Widget;
use SilverStripe\Widgets\Model\WidgetArea; use SilverStripe\Widgets\Model\WidgetArea;
use SilverStripe\Forms\CheckboxField;
/** /**
* Class \A2nt\CMSNiceties\Widgets\WidgetPageExtension * Class \A2nt\CMSNiceties\Widgets\WidgetPageExtension
@ -16,6 +17,10 @@ use SilverStripe\Widgets\Model\WidgetArea;
*/ */
class WidgetPageExtension extends \SilverStripe\Widgets\Extensions\WidgetPageExtension class WidgetPageExtension extends \SilverStripe\Widgets\Extensions\WidgetPageExtension
{ {
private static $db = [
'DisableSidebar' => 'Boolean(0)',
];
public function updateCMSFields(FieldList $fields) public function updateCMSFields(FieldList $fields)
{ {
parent::updateCMSFields($fields); parent::updateCMSFields($fields);
@ -23,8 +28,8 @@ class WidgetPageExtension extends \SilverStripe\Widgets\Extensions\WidgetPageExt
$tab = $fields->findOrMakeTab('Root.Widgets'); $tab = $fields->findOrMakeTab('Root.Widgets');
$tab->setTitle('Sidebar'); $tab->setTitle('Sidebar');
$tab->removeByName('SideBar'); $tab->removeByName('SideBar');
$tab->push(CheckboxField::create('DisableSidebar'));
$widgetTypes = WidgetAreaEditor::create('Sidebar')->AvailableWidgets(); $widgetTypes = WidgetAreaEditor::create('Sidebar')->AvailableWidgets();
$available = []; $available = [];

View File

@ -7,7 +7,7 @@
</div> </div>
<% end_if %> <% end_if %>
<% if $SideBarContent || $SideBarView && $SideBarView.Widgets.Count %> <% if not $DisableSidebar && $SideBarContent || $SideBarView && $SideBarView.Widgets.Count %>
<div class="content-holder content-holder__sidebar"> <div class="content-holder content-holder__sidebar">
<div class="{$DefaultContainer}"> <div class="{$DefaultContainer}">
<div class="row"> <div class="row">