Overiding Plugin Email template


#1

I have followed the docs in overriding a plugin’s template, for email templates.

I copied the .ctp files from the plugin and put it in the main app’s template:

app/src/Template/Plugins/Contacts/Email/html/new.ctp

I then edited that file but when the email run’s I still get the plugin’s version and not the main app’s one.


#2

If you have a plugin and it is enabled, it’s view files overrides the default views.
So you have to disable the plugin when you do not want it to take effect


#3

No, that’s not how it works. I’ve sucessfully had it working with the CakeDC users plugin, overwriting it’s templates yet still using the plugin functionality.


#4

As themes are plugins, you might need to use something like this in your controller method:

$this->viewBuilder()->setTheme(null);

That should turn off your “plugin-theme” for the following render action.


#5

Thanks, that is useful to know.

Turns out in the plugin a theme is used. So in that plugin model/controller the email is set to use a layout like this:

 ...->layout("PluginName.new");

If the plugin writer wrote instead:

...->layout("new");

I think that then would allow me to just drop in my own templates to override at main App level. I will try this… and suggest to plugin Author to make the change…


#6

It’s Plugin not Plugins.

Fuuuuuuuuuuuuuuuuuu…