Skip to content

Feature Request: Built in template output #12

@davejtoews

Description

@davejtoews

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 %>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions