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

[5.2] Feat: Introduce Mail Template Layout #43829

Merged
merged 27 commits into from
Jul 26, 2024

Conversation

LadySolveig
Copy link
Contributor

@LadySolveig LadySolveig commented Jul 23, 2024

Pull Request for Issue #39492 .

Summary of Changes

--The functionality for displaying the logo and sending it as an inline attachment depends on this fix #43828-- merged
--Depends on #43842 -- merged

Add support for mail template layouts as a parent wrapper around the existing mail templates.

  • ✅ A new default responsive mail template layout file mailtemplate.php for rendering mail content with sitename in footer and optional logo.
  • ✅ A new form field MailtemplateLayoutField to list available mail template layouts (overrides) from (frontend) templates.
  • ✅ Updates to MailTemplate class to handle layout data and render email content using the specified layout.
  • ✅ Configuration options in config.xml to enable/disable HTML layout and select a mail template layout globally.
  • ✅ Form updates in template.xml to include options for disabling HTML layout and selecting a mail template layout individual for each template.
  • ✅ Adjustments in TemplateModel to remove HTML layout fields when the mail style is set to plaintext.

Testing Instructions

Global Configuration -> Mail Templates

Set Mail Format--> HTML

Setup global Mail Templates configration for Mail Template Layouts as follows:

grafik

Scenario 1

Per Template Settings are disabled in the Global Configuration:

grafik

Go to System--> Mail Templates--> open Global Configuration: Test Mail
No additonal options in template edit view and the global settings are used.

grafik

Go to System --> Global Configuration--> Tab: Server

Scroll to the bottom and send out test mail

grafik

Your Test Mail should look similar like this

grafik

Scenario 2

Per Template Settings are enabled in the Global Configuration:

  • additonal options in template edit view with default settings to use the global options

grafik

grafik

Send the test mail again - the mail should look the same as in the previous step.

Scenario 3

Go to System--> Mail Templates--> open Global Configuration: Test Mail

grafik

Your Test Mail should look similar like this

grafik

Scenario 4

Go to System--> Site Templates--> open your Template --> Tab: Create Overrides and add override jooml->mail

Open file html --> joomla --> mail --> mailtemplate.php

and add this text

grafik

This is a test for template overrides

Go to System--> Mail Templates--> open Global Configuration: Test Mail

Set Logo File --> enables

Choose your layout override

grafik

Your Test Mail should look similar like this

grafik

Scenario 5

Go to System--> Mail Templates--> open Global Configuration: Test Mail

Choose Layout --> Use Global

Go to System--> Global Configuration--> Mail Templates

Choose your layout override

Your Test Mail should look like in the step before

Scenario 6

Go to System--> Global Configuration--> Mail Templates

grafik

Your Test Mail should look similar like this

grafik

Scenario 7

Go to System--> Global Configuration--> Mail Templates

Choose your layout override

grafik

Go to System--> Site Templates--> open your Template

Open file html --> joomla --> mail --> mailtemplate.php

and add this text

grafik

{METHOD}

Your Test Mail should look similar like this

grafik

Actual result BEFORE applying this Pull Request

grafik

Expected result AFTER applying this Pull Request

grafik

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-5.2-dev labels Jul 23, 2024
@LadySolveig LadySolveig marked this pull request as draft July 23, 2024 10:06
Co-authored-by: Brian Teeman <brian@teeman.net>
@brianteeman
Copy link
Contributor

Can I suggest changing this
image

to
image

@LadySolveig
Copy link
Contributor Author

@brianteeman if you want to change it by review in the language files I can commit directly :)

Co-authored-by: Brian Teeman <brian@teeman.net>
LadySolveig and others added 4 commits July 23, 2024 12:58
Co-authored-by: Brian Teeman <brian@teeman.net>
Co-authored-by: Brian Teeman <brian@teeman.net>
Co-authored-by: Brian Teeman <brian@teeman.net>
Co-authored-by: Brian Teeman <brian@teeman.net>
@brianteeman
Copy link
Contributor

I am really happy to see this. It's the missing link to truly make branded html mails.

Basic functionality all works great.

@brianteeman
Copy link
Contributor

When per template email setting is set to NO then I would not expect to see the layout options per email - is that an error/bug

When per template email setting is set to YES I have the option to enable the layout and select a layout but I cannot select an image - is that an error/bug or by design. I am hoping its an error/bug as I would use log as an image header

@Fedik
Copy link
Member

Fedik commented Jul 23, 2024

Thanks @LadySolveig . That it is very good feature.

Some thoughts for future.
What also would be cool, is to have an API to add inline images more freely, before layout rendering (or within the layout).
Kind of:

$mailTemplate->embedImages([
  'header-image' => 'path/to/image.jpg', 
  'logo-image' => 'path/to/logo.jpg'
]);
// Then in layout:
<img src="cid:header-image" alt="inline image"/>
<img src="cid:logo-image" alt="logo image"/>

But I not sure how to correctly interconnect it.

Do not code it here, just ideas for future. 😉

@coolcat-creations
Copy link
Contributor

how about solving the image "issue" like that, that the image must be always in a path with the template name? I totally see the need for different logos on several sites.

@bembelimen
Copy link
Contributor

Why then not just making a PR when this is merged?

@coolcat-creations
Copy link
Contributor

Why then not just making a PR when this is merged?

That would be fine too — otherwise the feature is lost in discussion.

@brianteeman
Copy link
Contributor

I have tested this item ✅ successfully on 1e2cb33


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43829.

1 similar comment
@chmst
Copy link
Contributor

chmst commented Jul 25, 2024

I have tested this item ✅ successfully on 1e2cb33


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43829.

@chmst
Copy link
Contributor

chmst commented Jul 25, 2024

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43829.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jul 25, 2024
@exlemor
Copy link

exlemor commented Jul 25, 2024

I have tested this item ✅ successfully on 1e2cb33

I was able to test this successfully.

As discussed with Martina, I should note that Scenarios 1-5, I had my Mailer set to PHP Mail and they worked fine, Scenario 6 gave an Could not instantiate mail function but when I switched the mailer to Sendmail that scenario worked. Scenario 7 worked on PHP Mail.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43829.

Copy link
Member

@HLeithner HLeithner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question in general, why do we need a layout.php file and not use the mail template component it self and save the base html layout in the database so people can adapt it easily at the place where all other mail layouts are stored?

libraries/src/Mail/MailTemplate.php Show resolved Hide resolved
libraries/src/Mail/MailTemplate.php Show resolved Hide resolved
@Fedik
Copy link
Member

Fedik commented Jul 26, 2024

save the base html layout in the database so people can adapt it easily

No please, it is like saving index.php of the main template in database.
It will be huge and unpractical.

@HLeithner
Copy link
Member

save the base html layout in the database so people can adapt it easily

No please, it is like saving index.php of the main template in database. It will be huge and unpractical.

tbh, we need to be more user friendly for end users and they are unable (or don't want to) to touch php documents.
In the provided layout is nothing fancy that needs php.

@Fedik
Copy link
Member

Fedik commented Jul 26, 2024

This kind of thing is for "advanced user", it is not average HTML that can be edited in TinyMCE.
However the layout can be provided as part of the site template (by template developers), and it can be edited as any other template file.

@LadySolveig
Copy link
Contributor Author

@HLeithner Is that what you mean by user friendly if I have to remember to adapt several templates (for each language one) individually in backend just because I want to change a mail from address for a single use case (MailTemplate), for example? ;)

@HLeithner
Copy link
Member

yeah don't care anyway please just fix the broken database query thanks

@brianteeman
Copy link
Contributor

I suspect most people will just be happy to have real html emails with the default layout - I know I am

Copy link
Member

@HLeithner HLeithner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@Hackwar Hackwar enabled auto-merge (squash) July 26, 2024 20:25
@Hackwar
Copy link
Member

Hackwar commented Jul 26, 2024

I'm merging this even though since this was set to RTC, additional changes were made. However those changes were basically codestyle fixes and have been reviewed by me.

Thank you for your contribution @LadySolveig! This will be a great feature.

@Hackwar Hackwar added this to the Joomla! 5.2.0 milestone Jul 26, 2024
@Hackwar Hackwar merged commit 7c34431 into joomla:5.2-dev Jul 26, 2024
3 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.