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

Allow plugins to use their own email templates when using e107::getEmail()->sendEmail(); #4919

Closed
CaMer0n opened this issue Dec 10, 2022 · 0 comments
Labels
topic: documentation type: enhancement An improvement or new feature request
Milestone

Comments

@CaMer0n
Copy link
Member

CaMer0n commented Dec 10, 2022

Motivation

Plugins may have a specific email layout or design that is unsupported by the currently installed theme (or core) email template.
Allowing plugins to use their own templates when sending emails solves this problem.

Proposed Solution

Have 'template' accept an array value:

  • plugin: plugin's folder
  • name: file name (ie. {name}_template.php )
  • key: array key within template.
$eml = array(
    'subject'		=> 'New Message',
    'body' 		=> "..",
    'template'		=> ['plugin'=>'_blank', 'name'=>'_blank', 'key'=>'email'],
    'shortcodes'	=> [
            'DATE'      => date('D, M d, Y'),
            'NAME'      => $user_name
    ],
);

e107::getEmail()->sendEmail('user@email.com', 'User Name', $eml);

The example above would load the following template.

e107_plugins/_blank/_blank_template.php (example)

$_BLANK_TEMPLATE['email']['header'] = '<html lang="en"><body>';
$_BLANK_TEMPLATE['email']['body'] = "<div><span>{NAME}</span> <small>{DATE}</small></div><div>{BODY}</div>";
$_BLANK_TEMPLATE['email']['footer'] = '</body></html>';

Custom template option

$eml = array(
    'subject'		=> 'New Message',
    'body' 		=> "..",
    'template'		=> [
        'subject' => '{SUBJECT}',
        'header' => '<html lang="en"><body>', 
        'body' => '<div><span>{NAME}</span> <small>{DATE}</small></div><div>{BODY}</div>', 
        'footer '=> '</body></html>'
    ],
    'shortcodes'	=> [
            'DATE'      => date('D, M d, Y'),
            'NAME'      => $user_name
    ],
);
@CaMer0n CaMer0n added the type: enhancement An improvement or new feature request label Dec 10, 2022
@CaMer0n CaMer0n added this to the e107 2.3.3 milestone Dec 10, 2022
@Moc Moc added this to Backlog in Documentation update via automation Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: documentation type: enhancement An improvement or new feature request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants