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

View File

@ -7,7 +7,7 @@
</div>
<% 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="{$DefaultContainer}">
<div class="row">