Skip to content

Commit

Permalink
FEATURE ImageSlide - include Link CTA (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish authored Oct 12, 2023
1 parent 5bc615d commit c3b456c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
],
"require": {
"jonom/focuspoint": "^5",
"silverstripe/linkfield":"^3.0",
"silverstripe/recipe-cms": "^5.0",
"symbiote/silverstripe-gridfieldextensions": "^4"
},
Expand Down
27 changes: 27 additions & 0 deletions src/Model/ImageSlide.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
namespace Dynamic\Carousel\Model;

use SilverStripe\Assets\Image;
use SilverStripe\Forms\FieldList;
use SilverStripe\LinkField\ORM\DBLink;
use SilverStripe\LinkField\Form\LinkField;

/**
* Class \Dynamic\Carousel\Model\ImageSlide
*
* @property string $DbLink
* @property int $ImageID
* @method Image Image()
*/
Expand All @@ -27,6 +31,10 @@ class ImageSlide extends Slide
*/
private static $plural_name = 'Image Slides';

private static $db = [
'DbLink' => DBLink::class
];

/**
* @var string[]
*/
Expand All @@ -42,4 +50,23 @@ class ImageSlide extends Slide
];

private static $hide_ancestor = Slide::class;

public function getCMSFields(): FieldList
{
$this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->addFieldsToTab(
'Root.Main',
[
$fields->dataFieldByName('Image')
->setFolderName('Uploads/Carousel/Slides'),
LinkField::create('DbLink')
->setTitle('Link'),
],
'Content'
);
});

return parent::getCMSFields();
;
}
}
1 change: 1 addition & 0 deletions templates/Dynamic/Carousel/Includes/ImageSlide.ss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<div class="carousel-caption d-none d-md-block">
<% if $Title && $ShowTitle %><h3>$Title</h3><% end_if %>
<% if $Content %>$Content<% end_if %>
<% if $DbLink %>$DbLink<% end_if %>
</div>

0 comments on commit c3b456c

Please sign in to comment.