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

Support NC12 #23

Closed
GitHubUser4234 opened this issue Jun 22, 2017 · 35 comments
Closed

Support NC12 #23

GitHubUser4234 opened this issue Jun 22, 2017 · 35 comments

Comments

@GitHubUser4234
Copy link

Hi,

Please release the mail template editor for NC 12, it's desperately needed, thanks!

@nickvergessen
Copy link
Member

Well the main issue is, that the emails are now themed with the new email template system.
There for the files this app used do not exist anymore.

What exactly do you want to change?

@GitHubUser4234
Copy link
Author

GitHubUser4234 commented Jun 22, 2017

Well the main issue is, that the emails are now themed with the new email template system.
There for the files this app used do not exist anymore.

What exactly do you want to change?

The goal is to be able to do the same as this app does. In our case we currently have defined the email content in email.new_user.php and email.new_user_plain_text.php. Is there a way to do this same as comfortably in the new email template system? A pointer where to find more info would be great, thanks.

But then, how come the app will be supported for NC13? 😄

@nickvergessen
Copy link
Member

Yeah so what do you want to change? the text of the email? the layout? add additional info?

If you want to change stuff for all emails, you can overwrite the EmailTemplate in the config with 12.0.1 and later: https://github.com/nextcloud/server/blob/8760abae636b1c6f3f37e78300b318adb98d0220/config/config.sample.php#L969-L974

@GitHubUser4234
Copy link
Author

GitHubUser4234 commented Jun 23, 2017

Yeah so what do you want to change? the text of the email? the layout? add additional info?

Text as well as layout.

If you want to change stuff for all emails, you can overwrite the EmailTemplate in the config with 12.0.1 and later: https://github.com/nextcloud/server/blob/8760abae636b1c6f3f37e78300b318adb98d0220/config/config.sample.php#L969-L974

Thanks for the pointer. However it doesn't look like the same, as the text of individual doesn't seem to be editable? And not as convenient as this app where things can be achieved by just quickly modifying some HTML.

It would be really awesome if this app could support NC12, after all support for NC13 is in the cards. It's really sad that with the NC12 upgrade, features like the ones offered by this app are not available anymore 😿

Seems others have also reported this problem:

https://help.nextcloud.com/t/email-templates-missing-nc-12/14356
https://help.nextcloud.com/t/missing-mailtemplate-editor/15114

@fabianblum
Copy link

Please update the manual if there is no Theming posibility in the admin page (https://docs.nextcloud.com/server/12/developer_manual/core/theming.html)

@TheMrApostel
Copy link

@nickvergessen
But how do i change the existing text?

@TheMrApostel
Copy link

Ping

@marley-ma
Copy link

marley-ma commented Aug 25, 2017

@TheMrApostel you can do this via translation layer. But it is a terrible approach!

@nickvergessen as mentioned above please update the manual!!!

@nickvergessen I looked closer at the source code of OC\Mail\EMailTemplate::class and I think it would be worthwhile to remake the mentioned class. A better approach to solve this, would certainly be to retrieve HTML parts individually from external file and not to define HTML as class properties directly in the given container. It is quite logical if we want to use our custom NextCloud theme so that we can also customize the layout of system emails without interfering with the PHP object.

@nickvergessen
Copy link
Member

Well the idea is that you create your own EmailTemplate class and then replace it the config.php. Then you can change the HTML as you prefer. For the next version we will add identifiers, so you can also only modify some emails.

And feel free to update the documentation with any changes you need

@SkyWheel
Copy link

So, in other words, there is no way to change an email template from web console?

@nickvergessen
Copy link
Member

Exactly, it's not there anymore, because if you break the php syntax by missing out a semicolon or something similar, you break sending the email completly.

@TheMrApostel
Copy link

Can someone please point me where i can change the code of OC\Mail\EMailTemplate::class?
It is still unclear to me where OC\Mail\EMailTemplate is located on my system.

@marley-ma
Copy link

@TheMrApostel it isn't good idea change code in OC\Mail\EMailTemplate::class.

Better way is create your own class like this example:

  1. Create your own OC\Mail\EMailTemplate::class extension
<?php namespace MyVendor;

use OC\Mail\EMailTemplate;

class MyClass extends EMailTemplate
{
      // there you can do what will you do
}
  1. Then in config/config.php change mail_template_class to your class namespace
'mail_template_class' => MyVendor\MyClass::class

@msberends
Copy link

Better way is create your own class like this example:

I find this hard to understand. Where do I save such a PHP file then? Somewhere in my /themes/MyTheme/core folder?

@nickvergessen
Copy link
Member

The clean way would be to have a dedicated app for it.
The otherway would be to just throw it into the normal source folder next to the existing one, but that will break with every update. So it's better to create your own app.

@MariusBluem status of the post I gave you?

@msberends
Copy link

msberends commented Sep 4, 2017 via email

@TheMrApostel
Copy link

@marley-ma @msberends

I find this also hard to understand. I had no problems by creating an webserver and install nextcloud with ldap and so on but i do not unterstand how to create my own extension. Can i copy and paste the code from NC11 there?

I also think that this should be a part of the core functions.
The new mail template is way too personal and inflexible.

@JK74
Copy link

JK74 commented Sep 6, 2017

@nickvergessen I'm now a bit confused as this issue is now closed but pointing to another thread #5180 however that thread is now pointing as well back to this one. The circle is round but still no fix? Or a future enhancement? Or do we get 2 more lines in the admin page that can be included in the invite e-mail for new users? Please advise as this is confusing. thanks!

@nickvergessen
Copy link
Member

Well see the comment from marley-ma above. It holds the info you are looking for

@msberends
Copy link

Uhm, right. I’ll consider the template editor unsupported on NC12. Even my theme logo isn’t in the mail :(

Anyway, thanks for your time.

@marley-ma
Copy link

@msberends are you sure that you have logo-mail.gif file in your theme?

see here

@msberends
Copy link

msberends commented Sep 6, 2017 via email

@TheMrApostel
Copy link

TheMrApostel commented Sep 8, 2017

@nickvergessen
So i just have to paste the text of my NC11 template in the code of @marley-ma ?
For example the standard template of NC11:

<?php namespace MyVendor;

use OC\Mail\EMailTemplate;

class MyClass extends EMailTemplate
{
<table cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr><td>
			<table cellspacing="0" cellpadding="0" border="0" width="600px">
				<tr>
					<td colspan="2" bgcolor="<?php p($theme->getMailHeaderColor());?>">
						<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/>
					</td>
				</tr>
				<tr><td colspan="2">&nbsp;</td></tr>
				<tr>
					<td width="20px">&nbsp;</td>
					<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
						<?php
						if ($_['onBehalfOf']) {
							print_unescaped($l->t('Hey there,<br><br>%s shared <a href="%s">%s</a> with you on behalf of %s.<br><br>', [$_['owner'], $_['link'], $_['filename'], $_['initiator']]));
						} else {
							print_unescaped($l->t('Hey there,<br><br>%s shared <a href="%s">%s</a> with you.<br><br>', [$_['owner'], $_['link'], $_['filename']]));
						}
						// TRANSLATORS term at the end of a mail
						p($l->t('Cheers!'));
						?>
					</td>
				</tr>
				<tr><td colspan="2">&nbsp;</td></tr>
				<tr>
					<td width="20px">&nbsp;</td>
					<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
						<?php p($theme->getName()); ?> -
						<?php p($theme->getSlogan()); ?>
						<br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl());?></a>
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
			</table>
		</td></tr>
</table>
}

@marley-ma
Copy link

@TheMrApostel no, that's not right.

  1. Look at the source code of extended class OC\Mail\EMailTemplate::class

  2. Then override what you need in your class extension

Example

Let's assume that we need override email header.

<?php namespace MyVendor;

use OC\Mail\EMailTemplate;

class MyClass extends EMailTemplate
{
    protected $header = <<<EOF 
        <table align="center" class="wrapper">
            // your theme email header modification
        </table>
    EOF;
}

Don't forget to set your class in the configuration. See point 2 in this comment

@TheMrApostel
Copy link

@marley-ma
I'm very sorry but i still dont get it.
From my understanding you can only change the template / design of the email.
I want to add some additional text / information. I took a look and the source code you had pointed me but i didn't found any text elements :(

Thank you for your kind help!

@GitHubUser4234
Copy link
Author

GitHubUser4234 commented Sep 17, 2017

I'm very sorry but i still dont get it.
From my understanding you can only change the template / design of the email.
I want to add some additional text / information. I took a look and the source code you had pointed me but i didn't found any text elements :(

Thank you for your kind help!

It looks like exactly that isn't possible, at least for individual emails? That's why this app (templateeditor) would still be needed but it doesn't support NC12.

@JimmyKater
Copy link

@nickvergessen

The clean way would be to have a dedicated app for it.

well... i'm afraid there WAS such an app. and as much as i can understand why you removed it from the appstore i am wondering why you don't just update it since it seems soooooooooo easy, as you implied in another posting from above.
and yes, email-template-changings are part of the official nc12-manual (so it most prolly will be dropped completely in nc13+, right?).

well to cut a long story short: a thing like "editing email-templates" is needed. and it should be an app itself (since modifying source code with every update isn't the best thing to do - as you put out earlier, yourself).

@nickvergessen
Copy link
Member

It looks like exactly that isn't possible, at least for individual emails? That's why this app (templateeditor) would still be needed but it doesn't support NC12.

This is possible with the new way as well. In 12.0.3 we added identifiers so text can be added to individual emails only.

As explain already multiple times, we won't fix this app or build a new one, because it's to complicated to make sure stuff still works correctly when we change an email. E.g. when we add a new feature to an email or remove one.

@JK74
Copy link

JK74 commented Sep 26, 2017

Nick, maybe I missed it from the release notes for 1203 but where is it documented how to change some e-mails? thnx again, Jeroen

@JaredBoone
Copy link

I was able to build a dedicated app and override the EMailTemplate class as described above. Thanks for pointing me in the right direction @nickvergessen .

I'll also add my voice to the chorus and say that I would like to see better support for custom email templates in the core application.

@msberends
Copy link

msberends commented Oct 12, 2017 via email

@alanlo52
Copy link

alanlo52 commented Nov 7, 2017

is there any update on this?
and i'm wonder how to create my own OC\Mail\EMailTemplate::class extension to where?

@MorrisJobke
Copy link
Member

and i'm wonder how to create my own OC\Mail\EMailTemplate::class extension to where?

See nextcloud/server#8350 (comment) for more details.

@rubo77
Copy link

rubo77 commented Aug 23, 2018

Here is a good explanation how to create your own template: https://help.nextcloud.com/t/solved-custimze-emails/23931/3

you can find the EmailTemplate in the following directory : nextcloud/lib/private/Mail/
Make a copy of the template and rename it. (Ex: NewEmailTemplate)
Make all the change you need in your new email template
then in the config.php (nextcloud/config/) add the following line

’mail_template_class’ => ’ \OC\Mail\NameOfYourEmailTemplate’,

@SkyWheel
Copy link

And what Nextcloud-snap users should do?

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