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

HTML hardcoded in mailer.php #2

Open
Arkileogisticologist opened this issue Aug 8, 2022 · 3 comments
Open

HTML hardcoded in mailer.php #2

Arkileogisticologist opened this issue Aug 8, 2022 · 3 comments

Comments

@Arkileogisticologist
Copy link

Hi! This is a really good alternative to the standard contact extension, but the template being hardcoded into mailer.php has me worried about making changes. Are there any plans to move the template to a separate file?

@GiovanniSalmeri
Copy link
Owner

Hello! First of all: I meant the contact form only as a very simple example of use of the API of email creation and transfer which this extension offers.

As regards HTML email, the hardcoded template (in lines 413-428) is actually nothing more than an essential boilerplate, which is identical in any HTML email. But the API gives the possibility of 1. specifying a CSS 2. specifying the heading 3. specifying the body 4. specifying the signature. If any of 2, 3, 4 is not specified, then the respective content is automatically obtained from the text/plain version, interpreted as markdown.

Presently none of these possibilities is used by the contact form. Normally, contact forms are meant to contact a society, and an elaborate formatting is in general of little use in this case. But nothing prevents from using some of the possibilities mentioned above. For example, in order to add a fancier signature one could add after line 50 (not tested):

$mail['text']['html']['signature'] = "<div style=\"background:yellow;padding:5px;font-size:1.2em\">".htmlspecialchars($page->getRequest('name'))."</div>\n";

Yes, this requires modifying the extension... but it would be easy to make a simple system of external templates. I could think about it. Could you say more exactly what is your use case?

@Arkileogisticologist
Copy link
Author

I'm using the extension as a simple contact form on a one-page website (the AJAX functionality is really useful in that respect). I've already modified the extension somewhat by adding the placeholder attribute on the form textarea and input tags (lines 63-73), and removed the labels above each field for a different look.

I'm not too concerned about doing anything too elaborate, and of course styling can always be done via a separate CSS file. My concern is more that if the extension is updated, I'll lose my modifications and will have to re-do them (AFAIK Yellow doesn't let you exclude an extension when updating).

@GiovanniSalmeri
Copy link
Owner

I understand. Finding the right balance between simplicity of use and configurability is always a matter of compromise. Generally I try to follow the spirit of Yellow, where the former is preferred, but I will think better to this question. If I devise a super-simple template system (for the form and for the email) which does not add too much complexity, I will update the extension. Thank you for asking!

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

2 participants