Skip to content

Commit

Permalink
added extra styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Makreig committed Jun 17, 2020
1 parent 65f3d70 commit 90c9f1c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/Model/CallToAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class CallToAction extends DataObject
'Title' => 'Varchar',
'ShortCode' => 'Varchar',
'ExtraClasses' => 'Varchar',
'Text' => 'Varchar',
'LightText' => 'Boolean'
'Text' => 'HTMLText',
'LightText' => 'Boolean',
'LinkDivider' => 'Varchar'
];

private static $has_many = [
Expand Down
7 changes: 6 additions & 1 deletion src/Widgets/CTAWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Widgets\Model\Widget;
use ilateral\SilverStripe\CallToAction\Model\CallToAction;
use NathanCox\HasOneAutocompleteField\Forms\HasOneAutocompleteField;
use SilverStripe\Forms\DropdownField;

if (!class_exists(Widget::class)) {
return;
Expand All @@ -24,7 +25,11 @@ class CTAWidget extends Widget
public function getCMSFields()
{
return new FieldList(
new HasOneAutocompleteField('CTA', 'Call to Action', CallToAction::class)
DropdownField::create(
'CTAID',
'Call to Action',
CallToAction::get()->map('ID', 'Title')
)->setEmptyString('choose one')
);
}
}
29 changes: 18 additions & 11 deletions templates/ilateral/SilverStripe/CallToAction/Model/CallToAction.ss
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<% with $CTA %>
<div class="call-to-action py-5 $ExtraClasses">
<div class="call-to-action pt-5 $ExtraClasses">
<div class="container text-center py-3">
<p class="h2 mb-0">
$Text
<% loop $Links %>
<% if LinkURL %>
<a{$IDAttr}{$ClassAttr} href="{$LinkURL}"{$TargetAttr}>
{$Title}
</a>
<% end_if %>
<% end_loop %>
</p>
<div class="row justify-content-center mx-0">
<div class="col-auto pl-0 pr-1">
$Text
</div>
<div class="col-auto pr-0 pl-1">
<p class="h2 mb-0">
<% loop $Links %>
<% if LinkURL %>
<a{$IDAttr}<% if $Up.LightText %> class="text-light"<% end_if %> href="{$LinkURL}"{$TargetAttr}>
{$Title}
</a>
<% if not $Last %>$Up.LinkDivider<% end_if %>
<% end_if %>
<% end_loop %>
</p>
</div>
</div>
</div>
</div>
<% end_with %>
16 changes: 16 additions & 0 deletions templates/ilateral/SilverStripe/CallToAction/Widgets/CTAWidget.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% with $CTA %>
<div class="call-to-action py-5 $ExtraClasses">
<div class="text-center py-3">
$Text
<p class="h2">
<% loop $Links %>
<% if LinkURL %>
<a{$IDAttr}<% if $Up.LightText %> class="text-light"<% end_if %> href="{$LinkURL}"{$TargetAttr}>
{$Title}
</a>
<% end_if %>
<% end_loop %>
</p>
</div>
</div>
<% end_with %>

0 comments on commit 90c9f1c

Please sign in to comment.