diff --git a/src/Element/ElementCard.php b/src/Element/ElementCard.php index 979ef5e..e53580e 100644 --- a/src/Element/ElementCard.php +++ b/src/Element/ElementCard.php @@ -59,6 +59,7 @@ class ElementCard extends BaseElement */ private static array $db = [ 'Content' => 'HTMLText', + 'Position' => 'Enum("Left, Right, Top", "Left")', ]; /** @@ -90,6 +91,9 @@ public function fieldLabels($includerelations = true) $labels['Title'] = _t(__CLASS__ . '.TitleLabel', 'Title'); $labels['Content'] = _t(__CLASS__ . '.ContentLabel', 'Description'); $labels['ElementLink'] = _t(__CLASS__ . '.ElementLinkLabel', 'Link'); + $labels['Position'] = _t(__CLASS__ . '.PositionLabel', 'Image Position'); + $labels['Image'] = _t(__CLASS__ . '.Image', 'Image'); + return $labels; } @@ -101,14 +105,20 @@ public function getCMSFields(): FieldList { $this->beforeUpdateCMSFields(function (FieldList $fields) { // @phpstan-ignore-next-line - $fields->dataFieldByName('Image') - ->setFolderName('Uploads/Elements/Card'); - - $fields->insertBefore('Content', $fields->dataFieldByName('Image')); + $fields->dataFieldByName('Content') + ->setRows(8); // @phpstan-ignore-next-line - $fields->dataFieldByName('Content') - ->setRows(5); + $fields->dataFieldByName('Image') + ->setFolderName('Uploads/Elements/Card'); + $fields->insertBefore('Position', $fields->dataFieldByName('Image')); + + $fields->dataFieldByName('Position') + ->setDescription(_t( + __CLASS__ . 'PositionDescription', + 'Position of the image in relation to the content. + Image will display on top at smaller breakpoints.' + )); $fields->replaceField( 'ElementLinkID', diff --git a/templates/Dynamic/Elements/Card/Elements/ElementCard.ss b/templates/Dynamic/Elements/Card/Elements/ElementCard.ss index d1b56e4..a7cd18a 100644 --- a/templates/Dynamic/Elements/Card/Elements/ElementCard.ss +++ b/templates/Dynamic/Elements/Card/Elements/ElementCard.ss @@ -1,14 +1,22 @@ -
target="_blank" rel="noopener noreferrer"<% end_if %>>$ElementLink.Title
<% end_if %> +target="_blank" rel="noopener noreferrer"<% end_if %>>$ElementLink.Title
<% end_if %> +