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

Changing mail template for com_contact no html body #44686

Closed
Pinkeltje opened this issue Jan 5, 2025 · 24 comments
Closed

Changing mail template for com_contact no html body #44686

Pinkeltje opened this issue Jan 5, 2025 · 24 comments

Comments

@Pinkeltje
Copy link

Steps to reproduce the issue

Fresh install of Joomla 5.2.2.
Go to mailtemplates and open Contacts: Contact Form Mail
Do nothing and just save

Expected result

Mail sent to admin contains contactform information

Actual result

Mail sent to admin only contains language constant COM_CONTACT_ENQUIRY_TEXT

System information (as much as possible)

Joomla 5.2.2
PHP 8.2.12

Additional comments

Database entries for Global Configuration: Test Mail which stays ok upon save and entry for Contacts: Contact Form Mail where hmtlbody is wrong
Image

@Fedik
Copy link
Member

Fedik commented Jan 5, 2025

That happen because TinyMCE forces every content to be inside a tag, and so it wrap the default text in to <p> when you opened it first time.

As work around:
Change editor to Codemirror (in global configuration), and edit that email template again, where remove <p> tag

@Pinkeltje
Copy link
Author

First of all I'm using JCE editor, second I know how to solve it by creating my own hmtl body that works without problems.
I just reported this as a bug, because inexperienced users might open the email template and then save it and having this problem. So I think there should be made a fix.

@Fedik
Copy link
Member

Fedik commented Jan 5, 2025

My comment is correct and adressed to everyone who will ever will hit this issue in the future. There is no easy fix for it.
I do not see why you complaining.

jce is based on tinymce.

@brianteeman
Copy link
Contributor

This is a bug which needs to be fixed

@Pinkeltje
Copy link
Author

Pinkeltje commented Jan 5, 2025

@brianteeman totally agree. I have enough knowledge to eiter remove entries from database or create my own html template, but this is not how it is supposed to work.
Same as this issue which has been reported multiple times. #44396

@fgsw
Copy link

fgsw commented Jan 5, 2025

Same as this issue which has been reported multiple times. #44396

Issue is labeled as bug.

@Fedik
Copy link
Member

Fedik commented Jan 5, 2025

This is the TinyMCE issue, the same as #44396, it is how TinyMCE works.

We probably could force Codemirror for HTML editing for emails, similar as it done for template files editing.
Or have an option to change the editor for Email template, that could be a good solution.

@Pinkeltje
Copy link
Author

@Fedik
With all due respect, this is of course complete nonsense. As you can see, and could have seen for yourself if you had bothered to test things, you could have seen that using JCE and customising html for mail to test email settings does work.
Furthermore, codemirror is anything but user-friendly and not suitable for inexperienced users.

@LadySolveig
Copy link
Contributor

There seems to be a lot of frustration here from your point of view @Pinkeltje. But with all due respect, this tone and the insinuations are completely unnecessary and missplaced. Many thanks, @Fedik, for your explanations and constructive suggestions on this issue. I think this will be very helpful for other people who unfortunately have to deal with the tooling themselves.

@LadySolveig
Copy link
Contributor

LadySolveig commented Jan 7, 2025

Back to the actual problem, as already mentioned, there is a conflict between the behaviour of the WYSIWYG editors, whether TinyMCE or JCE, and the creation of the templates when they are first saved.
I think the suggestion to force an editor such as CodeMirror is absolutely appropriate in this situation.

To be honest, I think this is absolutely sufficient, as an inexperienced user will probably end up very frustrated with the mail templates if he tries to style anything here, even with a WYSIWYG editor.

These editors are simply not designed for this and emails do not work 1:1 like an HTML page. In fact, an inexperienced user should not enter anything more than plain text here or use one of the countless free generators especially for emails in the www and then copy and paste directly here. This also ensures to some extent that the emails reach the recipients on all clients (Outlook, GMail, Thunderbird, etc.) and possibly in dark and light mode as the creator intended.

I think it's an even more frustrating experience for inexperienced users when they ‘build’ something here in painstaking work only to realise that it looks completely different on the recipients end.

@Pinkeltje
Copy link
Author

OK. I'll stop reporting bugs, though. I am apparently not taken seriously and assumptions are being made here without bothering to test.

@brianteeman
Copy link
Contributor

@Pinkeltje please dont stop reporting bugs. What you identified is a bug and it not correct to say that it can only be fixed by changing to use codemirror.

@LadySolveig it is NOT about styling the message to look like a web page but some simple markup such as even a bold tag

@brianteeman
Copy link
Contributor

@Fedik

That happen because TinyMCE forces every content to be inside a tag, and so it wrap the default text in to

when you opened it first time.

It doesnt have to do that - thats a configuration option

@Fedik
Copy link
Member

Fedik commented Jan 8, 2025

thats a configuration option

@brianteeman I would like to see that :)

@LadySolveig
Copy link
Contributor

OK. I'll stop reporting bugs, though. I am apparently not taken seriously and assumptions are being made here without bothering to test.

Too bad reporting bugs is one of the biggest gifts for this project to stay alive. I really appreciate your commitment @Pinkeltje !
Nevertheless, respectful behaviour is at least as important to move forward.

@brianteeman There are always several solutions to a problem. Fedir has so far been the only one to make a constructive suggestion. If, as you say, it is possible to configure this differently for TinyMCE in particular for the mail templates, then perhaps we could implement this in the CMS. However, this would probably not solve the issue for the creator? As he has pointed out that he installs and want to use JCE.

@brianteeman
Copy link
Contributor

brianteeman commented Jan 8, 2025

The problem is that the language constant should NOT be displayed in the html editor - it should be the language value. If you enable language debug then you will see that the language string is not found because it is looking for the langauge string in the ADMIN language file but the language string is only present in the SITE language file

I am not sure if the best solution is to add the string to the admin language file OR if the com_mails component should be updated to look in both the site and the admin files.

If you look at the function

public static function loadTranslationFiles($extension, $language = 'en-GB')
you will see that it is only ever loading the admin language files!!

You do not see the reported problem in any of the mail templates because they are all admin language strings as a super quick check would have shown

This is NOTHING to do with the editor being used and NOTHING to do with the editor wrapping strings in the html black element p

@brianteeman
Copy link
Contributor

As further confirmation that this is nothing to do with the html editor the exact same problem for the exact same reason exists for the com_contact mail templates when using PLAINTEXT

@brianteeman
Copy link
Contributor

The bug was caused by the changes made by @zero24 in #43475

@Fedik
Copy link
Member

Fedik commented Jan 8, 2025

Okay, then it is not an editor issue, thanks for checking.
I remember in past it was shown a language constant, untill user push some button. It seems I missed this change.

@brianteeman
Copy link
Contributor

would have saved upset if both you and @LadySolveig had actually looked at it before replying - but moving forward I am not sure on the best way forward.

  1. moving/copying the language strings to the admin language file (I can do that) but then it would only be for this component and others using the mail template system would face the same bug
  2. modify the function loadTranslationFiles to check the site language files - this would be the best approach but that change is above my skillset - perhaps @zero-24 can modify his code and submit a PR

@brianteeman
Copy link
Contributor

@Pinkeltje as a quick fix for yourself you can add these two lines to administrator\language\en-GB\com_contact.ini

COM_CONTACT_ENQUIRY_SUBJECT="{SITENAME}: {SUBJECT}"
COM_CONTACT_ENQUIRY_TEXT="This is an enquiry email via {URL} from:\n{NAME} <{EMAIL}>\n\n{BODY}\n\n{CUSTOMFIELDS}"

and then click on the reset buttons in the mail template
Image

@zero-24
Copy link
Contributor

zero-24 commented Jan 8, 2025

I can take a deeper look into this next week.

@Pinkeltje
Copy link
Author

Pinkeltje commented Jan 8, 2025

@brianteeman
Seems to be a missing language constant indeed. Added your constants to language overrides and now it works. But as said before, I just wanted to report the bug. We had this problem reported by a user on our Dutch Joomla forum. I already gave the solution to paste this in the code field of the html template, and that worked also:

<p>Dit is een aanvraag van: {NAME}</p>
<p>E-mail: {EMAIL}</p>
<p>Onderwerp: {SUBJECT}</p>
<p>Inhoud bericht: {BODY}</p>
<p>Via: {URL}</p>
<p>{CUSTOMFIELDS}</p>

@zero-24 Thanks for looking into it.
@Fedik and @LadySolveig
To show that it has nothing to do with the editor. This works like a charm:
Image

I think this should be an easy fix contrary to the fix for #44396

@zero-24
Copy link
Contributor

zero-24 commented Jan 13, 2025

Hi, please take a look into this PR: #44730
As there is a PR i will close this issue here. Thanks.

I think this should be an easy fix contrary to the fix for #44396

Yes thats more complicated. Could be solved by letting the strings beeing edited with an editor but I'm sorry will not have the time to dig deeper into that Issue.

@zero-24 zero-24 closed this as completed Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants