Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Built in template output #12

Open
davejtoews opened this issue Feb 24, 2023 · 0 comments
Open

Feature Request: Built in template output #12

davejtoews opened this issue Feb 24, 2023 · 0 comments

Comments

@davejtoews
Copy link
Contributor

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 %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant