I frequently add a dataExtension to LinkItem to define a forTemplate method so I can directly invoke the object in a template. Would be willing to submit a PR if it will be accepted.
Something like.
LinkItem.php
private static $ExtraClass;
public function forTemplate($ExtraClass = '')
{
$this->owner->ExtraClass = $ExtraClass;
return $this->owner->renderWith('CyberDuck/LinkItemField/Partials/CTA');
}
public function Button($ExtraClass = '')
{
$this->owner->ExtraClass = $ExtraClass;
return $this->owner->renderWith('CyberDuck/LinkItemField/Partials/CTA');
}
CTA.ss
<% if $Exists %>
<a href="$Link" class="cta cta-$LinkType $ExtraClass" target="$Target" title="Go To $Title">
$Title
</a>
<% end_if %>
Button.ss
<% if $Exists %>
<a href="$Link" class="button button-$LinkType $ExtraClass" target="$Target" title="Go To $Title">
$Title
</a>
<% end_if %>
I frequently add a dataExtension to LinkItem to define a
forTemplatemethod so I can directly invoke the object in a template. Would be willing to submit a PR if it will be accepted.Something like.
LinkItem.php
CTA.ss
Button.ss