October: Register mail layouts and mail partials in a plugin

Created on 25 Sep 2018  路  4Comments  路  Source: octobercms/october

Expected behavior

A plugin should be able to publish its own mail layouts and partials, like the System\Classes\PluginBase::registerMailTemplates method.

Actual behavior

There is no easy way to integrate layouts or partials of a plugin

October build

current

Response Needed Conceptual Enhancement

Most helpful comment

I register layouts and partials like this:

use System\Classes\MailManager;

class Plugin extends PluginBase
{
    public function register()
    {
        MailManager::instance()->registerCallback(function ($manager) {
            $manager->registerMailLayouts([
                'l-welcome' => 'akme.plugin::mail.layout-welcome',
            ]);
            $manager->registerMailPartials([
                'p-head'    => 'akme.plugin::mail.partial-head',
                'p-header'  => 'akme.plugin::mail.partial-header',
                'p-body'    => 'akme.plugin::mail.partial-body',
                'p-footer'  => 'akme.plugin::mail.partial-footer',
                'p-picture' => 'akme.plugin::mail.partial-picture',
            ]);
        });
    }
}

All 4 comments

@TimFoerster feel free to submit a PR to introduce that feature :) Will need an accompanying docs entry

I register layouts and partials like this:

use System\Classes\MailManager;

class Plugin extends PluginBase
{
    public function register()
    {
        MailManager::instance()->registerCallback(function ($manager) {
            $manager->registerMailLayouts([
                'l-welcome' => 'akme.plugin::mail.layout-welcome',
            ]);
            $manager->registerMailPartials([
                'p-head'    => 'akme.plugin::mail.partial-head',
                'p-header'  => 'akme.plugin::mail.partial-header',
                'p-body'    => 'akme.plugin::mail.partial-body',
                'p-footer'  => 'akme.plugin::mail.partial-footer',
                'p-picture' => 'akme.plugin::mail.partial-picture',
            ]);
        });
    }
}

Support to register partials has been added in https://github.com/octobercms/october/pull/3847

implemented by #3850

Was this page helpful?
0 / 5 - 0 ratings