IMPROVEMENT: widgets areas

This commit is contained in:
Tony Air 2019-12-12 22:15:44 +07:00
parent cbf386f9a3
commit fdebf4abef
6 changed files with 36 additions and 8 deletions

View File

@ -60,6 +60,8 @@ SilverStripe\Blog\Model\BlogPost:
SilverStripe\Widgets\Model\Widget:
icon: '<i class="icon font-icon-p-document"></i>'
extensions:
- Site\Widgets\WidgetExtension
SilverStripe\Blog\Widgets\BlogArchiveWidget:
icon: '<i class="icon font-icon-p-archive"></i>'
SilverStripe\Blog\Widgets\BlogCategoriesWidget:

View File

@ -21,10 +21,6 @@ class BannerWidget extends Widget
private static $icon = '<i class="icon font-icon-block-banner"></i>';
private static $table_name = 'BannerWidget';
private static $db = [
'Title' => 'Varchar(255)',
];
private static $has_one = [
'Image' => Image::class,
'Link' => Link::class,

View File

@ -0,0 +1,28 @@
<?php
namespace Site\Widgets;
use DNADesign\Elemental\Forms\TextCheckboxGroupField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;
class WidgetExtension extends DataExtension
{
private static $db = [
'ShowTitle' => 'Boolean(1)',
];
public function updateCMSFields(FieldList $fields)
{
parent::updateCMSFields($fields);
// Add a combined field for "Title" and "Displayed" checkbox in a Bootstrap input group
$fields->removeByName('ShowTitle');
$fields->replaceField(
'Title',
TextCheckboxGroupField::create()
->setName('Title')
);
}
}

View File

@ -1,5 +1,7 @@
<div class="page-content">
<h1 class="page-header $DefaultContainer<% if $ElementalArea.Elements.Count < 1 %> no-elements<% end_if %>">$Title</h1>
<h1 class="element page-header $DefaultContainer<% if $ElementalArea.Elements.Count < 1 %> no-elements<% end_if %>">
$Title
</h1>
<div class="page-content">
<% if $CurrentElement %>

View File

@ -27,7 +27,7 @@
$Layout
</div>
<div class="col-md-4">
<div class="page-content">
<div class="sidebar page-content">
$SideBarView
</div>
</div>

View File

@ -1,4 +1,4 @@
<nav class="secondary element">
<% if $Title %><h2 class="widget-title">$Title</h2><% end_if %>
<nav class="secondary element $ClassName">
<% if $ShowTitle && $Title %><h2 class="widget-title">$Title</h2><% end_if %>
$Content
</nav>