IMPR: Multi-slider

This commit is contained in:
Tony Air 2022-04-19 13:50:36 +02:00
parent d955523d45
commit 0fb2342887
4 changed files with 61 additions and 2 deletions

View File

@ -62,3 +62,7 @@ Dynamic\Elements\Image\Elements\ElementImage:
DNADesign\ElementalVirtual\Model\ElementVirtual: DNADesign\ElementalVirtual\Model\ElementVirtual:
controller_template: VirtualElementHolder controller_template: VirtualElementHolder
Dynamic\FlexSlider\Model\SlideImage:
extensions:
- A2nt\ElementalBasics\Extensions\SlideImageEx

View File

@ -8,9 +8,11 @@
namespace A2nt\ElementalBasics\Elements; namespace A2nt\ElementalBasics\Elements;
use Colymba\BulkUpload\BulkUploader;
use Dynamic\Elements\Flexslider\Elements\ElementSlideshow; use Dynamic\Elements\Flexslider\Elements\ElementSlideshow;
use Dynamic\FlexSlider\Model\SlideImage; use Dynamic\FlexSlider\Model\SlideImage;
use Dynamic\FlexSlider\ORM\FlexSlider; use Dynamic\FlexSlider\ORM\FlexSlider;
use SilverStripe\Assets\Image;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\LiteralField;
@ -33,6 +35,7 @@ class SliderElement extends ElementSlideshow
private static $db = [ private static $db = [
'Interval' => 'Int', 'Interval' => 'Int',
'SlidesInRow' => 'Int',
]; ];
private static $extensions = [ private static $extensions = [
@ -79,13 +82,20 @@ class SliderElement extends ElementSlideshow
]); ]);
$fields->addFieldsToTab('Root.Settings', [ $fields->addFieldsToTab('Root.Settings', [
NumericField::create('Interval', 'Auto-play Interval'), NumericField::create('Interval', 'Auto-play Interval (sec)'),
NumericField::create('SlidesInRow'),
]); ]);
$grid = $fields->dataFieldByName('Slides'); $grid = $fields->dataFieldByName('Slides');
if ($grid) { if ($grid) {
$config = $grid->getConfig(); $config = $grid->getConfig();
/*$bulk = new BulkUploader('Image', Image::class, true);
$bulk
->setUfSetup('setFolderName', 'Uploads/SlideImages');
$config->addComponent($bulk);*/
$columns = new GridFieldEditableColumns(); $columns = new GridFieldEditableColumns();
$columns->setDisplayFields([ $columns->setDisplayFields([
'Hide' => [ 'Hide' => [

32
src/Extensions/SlideImageEx.php Executable file
View File

@ -0,0 +1,32 @@
<?php
/**
* Created by PhpStorm.
* User: tony
* Date: 6/23/18
* Time: 1:23 PM
*/
namespace A2nt\ElementalBasics\Extensions;
use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\ValidationResult;
class SlideImageEx extends DataExtension
{
/*public function onBulkUpload()
{
die('saadsadssdsda2222');
}
public function validate(ValidationResult $validationResult)
{
if (!$this->owner->Name) {
$this->owner->Name = rand();
}
}*/
}

View File

@ -9,7 +9,20 @@
<% if $SlideShow %> <% if $SlideShow %>
<div class="element__content"> <div class="element__content">
<div id="Carousel{$ID}" class="element__carousel carousel slide js-carousel"<% if $SlideShow.count > 1 %><% if $Interval %> data-bs-interval="$Interval"<% end_if %> data-bs-indicators="true" data-bs-arrows="true"<% end_if %>> <div
id="Carousel{$ID}"
class="element__carousel carousel slide js-carousel
<% if $SlidesInRow > 1 %>
carousel-multislide
<% end_if %>"
<% if $SlidesInRow > 1 %>
data-length="{$SlidesInRow}"
<% end_if %>
<% if $SlideShow.count > 1 %>
<% if $Interval %> data-bs-interval="$Interval"<% end_if %>
data-bs-indicators="true" data-bs-arrows="true"
<% end_if %>
>
<div class="carousel-inner"> <div class="carousel-inner">
<% loop $SlideShow %> <% loop $SlideShow %>
<div class="carousel-item carousel-item-{$SlideType}<% if no $Controls %> carousel-item-nocontrols<% end_if %><% if $First %> active<% end_if %>"> <div class="carousel-item carousel-item-{$SlideType}<% if no $Controls %> carousel-item-nocontrols<% end_if %><% if $First %> active<% end_if %>">