2017 © Pedro Peláez
 

yii2-extension yii2-email-templates

Module for adding templates for email letters across dashboard

image

black-lamp/yii2-email-templates

Module for adding templates for email letters across dashboard

  • Monday, May 15, 2017
  • by GutsVadim
  • Repository
  • 5 Watchers
  • 8 Stars
  • 273 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 9 Versions
  • 9 % Grown

The README.md

Email templates module for Yii2

Module for adding templates for email letters across dashboard, (*1)

Build Status Latest Stable Version Latest Unstable Version License, (*2)

Installation

Run command

composer require black-lamp/yii2-email-templates

or add, (*3)

"black-lamp/yii2-email-templates": "^3.0.0"

to the require section of your composer.json., (*4)

Applying migrations

yii migrate --migrationPath=@vendor/black-lamp/yii2-email-templates/src/migrations

Add module to application config

Backend module for create, edit and delete email templates, (*5)

'modules' => [
     // ...
     'email-templates' => [
         'class' => bl\emailTemplates\EmailTemplates::class,
         'languageProvider' => [
            'class' => bl\emailTemplates\providers\DbLanguageProvider::class,
            'tableName' => 'language',
            'idField' => 'id',
            'nameField' => 'name'
         ]
     ],
]

languageProvider it's a class that implements LanguageProviderInterface. You can use language providers from this extension or create yours. This extension has two language providers., (*6)

Database language provider configuration properties
Option Description Type Default
tableName Name of table in database with languages string language
idField Name of field in language table with primary key string id
idName Name of field in language table with language name string name
Config language provider configuration properties
Option Description Type Default
languages Array with languages. Example [1 => 'English', 2 => 'Russian'] array -
defaultLanguage Array with default language. Array must contains one value. Example [1 => 'English'] array -

Add component to application config

Component for getting the templates from database, (*7)

'components' => [
    // ...
    'emailTemplates' => [
        'class' => bl\emailTemplates\components\TemplateManager::class
    ],
]

Using

1) Create the template with markers across dashboard, (*8)

Email subject, (*9)

New message from {sitename}, (*10)

Email body, (*11)

Hello, {username}!, (*12)

Text..., (*13)

Go to the link - {link}, (*14)

2) Get template by key with component help, (*15)

$template = Yii::$app->templateManager->getTemplate('test', 1);

This method return a Template object., (*16)

3) You should to parse the markers in email subject and email body, (*17)

    $template->parseSubject([
        '{sitename}' => $sitename
    ]);

    $template->parseBody([
        '{username}' => Yii::$app->user->identity->firstname,
        '{link}' => Url::toRoute(['/confirm', 'token' => $token], true)
    ]);

4) Now you can using this template, (*18)

Yii::$app->mailer->compose()
    // ...
    ->setSubject($template->subject)
    ->setHtmlBody($template->body)
    // ...

The Versions

15/05 2017

dev-master

9999999-dev

Module for adding templates for email letters across dashboard

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

email template yii2 module delivery

15/05 2017

3.1.1

3.1.1.0

Module for adding templates for email letters across dashboard

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

email template yii2 module delivery

03/02 2017

3.1.0

3.1.0.0

Module for adding templates for email letters across dashboard

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

email template yii2 module delivery

17/01 2017

3.0.0

3.0.0.0

Module for adding templates for email letters across dashboard

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

email template yii2 module delivery

19/12 2016

2.1.0

2.1.0.0

Module for adding templates for email letters across dashboard

  Sources   Download

BSD 3-Clause License

The Requires

 

The Development Requires

by Vladimir Kuprienko

email template yii2 module delivery

13/12 2016

2.0.0

2.0.0.0

Module for adding templates for email letters across dashboard

  Sources   Download

GNU Public License

The Requires

 

The Development Requires

by Vladimir Kuprienko

email template yii2 module delivery

29/11 2016

1.0.2

1.0.2.0

Module for adding email templates across dashboard

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

email template yii2 delivery

29/11 2016

1.0.1

1.0.1.0

Module for adding email templates across dashboard

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

email template yii2 delivery

29/11 2016

1.0.0

1.0.0.0

Module for adding email templates across dashboard

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

email template yii2 delivery