Creating a Layout Override
This feature also allows you to create mail template layout overrides for your active site template. By creating layout overrides, you can customize the general or specific layout of emails sent using the Mail Templates function without the risk of losing changes during future Joomla updates. You can create as many Mail Template layout overrides as you need, and you can also use a different layout for each Mail Template if necessary.
To create a mail template override, first do the following once:
- Go to System -> Site Templates -> Open your template (e.g., Cassiopeia) Details and Files.
- Click the Create Overrides tab and then select joomla -> mail.
- This will make Joomla! copy the mailtemplate.php file to your template's '/html/layouts/joomla/mail/' directory, where you can modify it as needed.
Once the override is created, you can edit the layout override file and customize the styles of your emails without affecting the base template.
Custom Layouts
When you created your layout override, you made a copy of the file mailtemplate.php, which is the name of the default file that comes with the Joomla! distribution. The default layout is a table with 3 content rows. The first row will contain the logo you uploaded into the Mail Templates Global Options. If you did not upload a logo, your site name will appear in this row. The second row will contain the message generated by the extension utilizing Mail Templates. The third row will contain a copyright footer with the current year and your site name and URL. This may not be what you want your mails to look like, which is where making a custom layout comes in.
The layout file is PHP, but it contains a lot of HTML as well. You'll want to be familiar with this type of template to make changes, though it might be worthwhile to create a new layout with a WYSIWYG editor and then embed the necessary PHP code into the HTML created by that editor. Just make sure the file you edit is the one at '/html/layouts/joomla/mail/', which is the overrides folder.
Your file(s) do not need to be named mailtemplate.php and you can create as many different ones as you want. In the Mail Templates Global Options you select the one you want Mail Templates to use by default for all Mail Templates. The names of all .php files in the '/html/layouts/joomla/mail/' folder will appear in the Layout drop list. Shown here is the initial override layout file created. Selecting Default for Layout here will cause the original distribution's layout file to be used.
Testing and Configuration
- Ensure the Mail Template Global Options are configured according to your needs, including the default layout you prefer.
- If individual template settings are enabled, go to System -> Mail Templates, click on the Mail Template you want to configure, then click on the Options tab.
- If you created a Custom Layout for this Mail Template, set Mail Template Layout to Enabled, then select the Layout you want to use for this Mail Template.
- If you want your Mail Templates logo to appear in these messages, set Logo File to Enabled.
- Send a test mail to verify that the global or template-specific settings are applied correctly.
It may be easiest to use the Mass User Mails template to do this sort of testing since you can send those messages directly without having to provoke the internal system function that uses one of the other Mail Templates. You'll benefit from creating a special (e.g. "Testing") user group that includes at least one user with another of your own email addresses other than the Administrator account you are using. Select that group when sending the test message.